Kevin Vance - Adding the capability of multiple screenshots per project to…

Entries | Archive | Friends | Friends' Friends | User Info

02:00 am

Sunday, April 30th, 2006
Previous Entry Share Next Entry
Adding the capability of multiple screenshots per project to, so now I want a single screenshot like /screenshots/kevedit.png to be /screenshots/kevedit/default.png. I <3 my zsh:

% for name in *.*
    mkdir $name:r && cp -v $name $name:r/default.$name:e
`427assn4.jpg' -> `427assn4/default.jpg'
`areocon.png' -> `areocon/default.png'

I was kind of hoping to do this whole dynamic thing with Apache::Request, but I don't know enough about mod_perl to tell if I couldn't set it up properly or if it's just not enabled for my account type. mod_rewrite and are getting the job done, though. And HTML::Template. Omigod you guys, why didn't anyone tell me about HTML::Template before?

I'm finding it somewhat difficult to say what I mean /gracefully/ in perl, but it's been getting better. I mean, I love that in theory I can write a line like this (basically from the perlfunc manpage):

@files = grep { /\.(png|jpg)$/ && -f "$shots_dir/$_" } readdir($dir)

But then I want to extract /^default\..{3}$/ while removing it from the list, and I guess I should use map, but I can't figure out a nice way to extract and filter at the same time.

Link )Reply )

[User Picture]From: dormando
2006-04-30 06:14 am (UTC)
Two pass? I guess it's pointless to not just use a for at that point... Every time I write a map/grep that needs to extract and filter I wonder about the problem for a couple minutes before giving up.

Usually I end up with something gross abusing the ability to modify the elements: @files = grep { $_ } (grep { /^filter$/ ? $_ : $_ = undef } @whatever)

Still doesn't feel right and is a hell of a lot slower than just for'ing it.
(Reply) (Thread)