in reply to Map not giving me what I thought it would.
my @array = map { s/^-// } @ARGV;
two things are happening. First, the subtitution is changing $_ which is actually a reference to an element in @ARGV. Like in foreach when you change $_ in a map or grep it affects the item in the array being based to map or grep. As for the values in @array, they are always 1 in your example because the result of s/^-// is 1 (true) when the substitution succeeds, and false otherwise.
|
|---|