http://www.perlmonks.org?node_id=694730

harishnuti has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, i figured out 2 methods of trimming leading and trailing whitespaces of array elements in one go..
# Assume @array containing strings,elements etc $_ =~ s/^\s*(.*?)\s*$/$1/ for @array; # method one map { $_ =~ s/^\s*(.*?)\s*$/$1/} @array; # method two # Though i understand map is not meant for what i have done above, pls + tell me which is correct usage interms of perl standards # if any other one line methods of trimming would be good # Also how do i trim all Keys/value pairs of Hash