@out_list=@in_list; s/foo(.*?)bar/$1 baz/ for @in_list; #### @out_list = map {local $_=$_; s/foo(.*?)bar/$1 baz/; $_ } @in_list; #### 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"; #### # lc the filenames and create a set of filespecs from them. my @filespecs=map{ $_=lc($_); File::Spec->joinpath($path,$_) } @files;