Check up on the return value of s///. In this case, your s/// always returns 1 (the number of substititions made in that iteration). map takes all those 1s and assigns them to @users. You need to return the changed value to map.
Also, your usage of map clobbers the value passed to map. True, it doesn't matter in this instance, but it's a bad habit.
my @users = map { my $s = $_; # Protect the caller. chomp($s); $s =~ s/^\Q$MAIL_ROOT//; $s } `find ...`; # Return the changed value.
Both List::MoreUtils and Algorithm::Loops provide a function that does this magic for you.
use List::MoreUtils qw( apply ); my @users = apply { chomp; s/^\Q$MAIL_ROOT//; } `find ...`;
use Algorithm::Loops qw( Filter ); my @users = Filter { chomp; s/^\Q$MAIL_ROOT//; } `find ...`;
Update: I fixed your regexp.
In reply to Re: using map to replace text without using a foreach....
by ikegami
in thread using map to replace text without using a foreach....
by dark314
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |