Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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


Comment on Re: Strip leading and trailing blanks
Download Code
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 making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2015-07-01 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (19 votes), past polls