in reply to chomp not working in array

As has been mentioned, chomp only removes $/ from the end of things. See also perldoc -q "blank space"

Found in /System/Library/Perl/5.8.1/pods/perlfaq4.pod How do I strip blank space from the beginning/end of a string? Although the simplest approach would seem to be $string =~ s/^\s*(.*?)\s*$/$1/; not only is this unnecessarily slow and destructive, it also fa +ils with embedded newlines. It is much faster to do this operation in t +wo steps: $string =~ s/^\s+//; $string =~ s/\s+$//; Or more nicely written as: for ($string) { s/^\s+//; s/\s+$//; } This idiom takes advantage of the "foreach" loop's aliasing beh +avior to factor out common code. You can do this on several strings at +once, or arrays, or even the values of a hash if you use a slice: # trim whitespace in the scalar, the array, # and all the values in the hash foreach ($scalar, @array, @hash{keys %hash}) { s/^\s+//; s/\s+$//; }