in reply to Unexpected behavior with "map"
You just need to return at the end, not assign (and you can save some backwhacking in your s/// by picking a different delimiter):my @newlist = map { my $l = $_; $l =~ s/\/etc\///; my $l2 = $l; } @oldlist;
Or you can use Filter() from Algorithm::Loops.my @newlist = map { my $l = $_; $l =~ s|/etc/||; $l; } @oldlist;
Update: I forgot about the 'r' modifier for s///. It makes s/// return the new value. So if you have a new enough perl, you can do:
my @newlist = s|/etc||r, @oldlist;
|
|---|