in reply to A "harmless" alternative to 'map{}'?
Update:@out_list=@in_list; s/foo(.*?)bar/$1 baz/ for @in_list;
Anyway, heres a sub so you can write it the way that feels comfortable@out_list = map {local $_=$_; s/foo(.*?)bar/$1 baz/; $_ } @in_list;
One could argue that this dual result from the mapped code block -- doing in-place editing of the input list and also returning the edited list -- seems to be overdoing it, or is somewhat redundant.sub ro_map (&@){ my $sub=shift; my @return; foreach (@_) { local $_=$_; push @return,$sub->(); } @return } my @out=ro_map{s/x/y/g}@in; print "original: @in\n"; print "changed : @out\n";
I dont think you would get far with this argument. Howabout this:
HTH# lc the filenames and create a set of filespecs from them. my @filespecs=map{ $_=lc($_); File::Spec->joinpath($path,$_) } @files;
Now on to read the other comments. :-)
Yves / DeMerphq
---
Software Engineering is Programming when you can't. -- E. W. Dijkstra (RIP)
|
|---|