What should be done instead:
my @list= qw(first_string second_string); @list = map((s/_string$// and $_), @list); print @list;
This should be done only if one wishes to reduce all strings on which no substitution is done to empty strings:
>perl -wMstrict -le "my @list= qw(first_string second_string THIRD fourth_string); @list = map((s/_string$// and $_), @list); printf qq{'$_' } for @list; " 'first' 'second' '' 'fourth'
If this is not the case, BrowserUk has shown some alternatives.
In reply to Re: using map and swap (aka substitute)
by AnomalousMonk
in thread using map and swap (aka substitute)
by DamianKaelGreen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |