Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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.

--
http://fruiture.de

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.

        --k.


Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2016-08-30 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (410 votes). Check out past polls.