Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: chomp not working in array

by monoxide (Beadle)
on Nov 15, 2004 at 21:06 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2024-03-28 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found