Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: chomp not working in array

by monoxide (Beadle)
on Nov 15, 2004 at 21:06 UTC ( #407958=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://407958]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2021-03-09 01:53 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (129 votes). Check out past polls.