in reply to chomp not working in array

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: chomp not working in array
by diotalevi (Canon) on Nov 15, 2004 at 21:51 UTC

    Let me elaborate on pg's note. Not only will chomp not do what you hoped, using reverse is needlessly expensive. This is better written using two efficient s/// expressions.

    for ( @phrase ) { s/^\s+//; s/\s+$//; print "$_\n"; }
Re^2: chomp not working in array
by pg (Canon) on Nov 15, 2004 at 21:23 UTC

    This will not work. As others pointed out, chomp does not chomp white spaces.

    Your reverse() trick will work ;-) if chomp chomps trailing white spaces.