# 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