my @oldlist = qw X /etc/passwd /etc/group /etc/shadow X; #### my @newlist = map s/\/etc\/// , @oldlist; #### $ $ cat t.pl #!/usr/bin/perl use strict; use warnings; my @oldlist = qw X /etc/passwd /etc/group /egg/drop /etc/shadow X; my @newlist = map s/\/etc\/// , @oldlist; print "\nAfter map (newlist)\n"; print "=========\n"; foreach (@newlist) { print "$_\n"; } $ ./t.pl After map (newlist) ========= 1 1 1 $ #### $ cat ta.pl #!/usr/bin/perl use strict; use warnings; my @oldlist = qw X /etc/passwd /etc/group /egg/drop /etc/shadow X; print "\nBefore map (oldlist)\n"; print "==========\n"; foreach (@oldlist) { print "$_\n"; } my @newlist = map s/\/etc\/// , @oldlist; print "\nAfter map (oldlist)\n"; print "=========\n"; foreach (@oldlist) { print "$_\n"; } print "\nAfter map (newlist)\n"; print "=========\n"; foreach (@newlist) { print "$_\n"; } $ ./ta.pl Before map (oldlist) ========== /etc/passwd /etc/group /egg/drop /etc/shadow After map (oldlist) ========= passwd group /egg/drop shadow After map (newlist) ========= 1 1 1 $ #### my @newlist = map { my $l = $_; $l =~ s/\/etc\///; } @oldlist; #### $ ./tb.pl Before map (oldlist) ========== /etc/passwd /etc/group /egg/drop /etc/shadow After map (oldlist) ========= /etc/passwd /etc/group /egg/drop /etc/shadow After map (newlist) ========= 1 1 1 $ #### $ cat tc.pl #!/usr/bin/perl use strict; use warnings; my @oldlist = qw X /etc/passwd /etc/group /egg/drop /etc/shadow X; my @newlist = map { my $l = $_; $l =~ s/\/etc\///; my $l2 = $l; } @oldlist; print "\nAfter map (oldlist)\n"; print "=========\n"; foreach (@oldlist) { print "$_\n"; } print "\nAfter map (newlist)\n"; print "=========\n"; foreach (@newlist) { print "$_\n"; } $ ./tc.pl After map (oldlist) ========= /etc/passwd /etc/group /egg/drop /etc/shadow After map (newlist) ========= passwd group /egg/drop shadow $