Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Strip leading and trailing blanks

by fruiture (Curate)
on Jul 29, 2003 at 21:16 UTC ( #278995=note: print w/replies, xml ) Need Help??

in reply to Strip leading and trailing blanks

Because this is a common problem (and _has_ been answered here before) i can tell that there is a very efficient way to do it (probably the most efficient one of the less complicated):

s/^\s+//; s/\s+$//;

See perlop and perlre.


Replies are listed 'Best First'.
Re: Re: Strip leading and trailing blanks
by Kanji (Parson) on Jul 29, 2003 at 22:22 UTC

    Check out trim() by japhy... a really neat sub that wraps and builds upon this very solution.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2016-10-22 12:29 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (294 votes). Check out past polls.