Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Answer: How can I strip an arbitary number of leading spaces from a string?

by japhy (Canon)
on Sep 25, 2000 at 21:04 UTC ( #33931=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How can I strip an arbitary number of leading spaces from a string? - Answer contributed by japhy

There is no need to use s/^\s*//. This will waste time on strings with no leading space. Use s/^\s+// at all times -- it obviously won't do anything if there's no whitespace to match.

A general rule of thumb is that s/X*// is slower than s/X+//, and in cases where the RHS (right-hand side) is something OTHER than "", chances are you really do mean X+.

  • Comment on Answer: How can I strip an arbitary number of leading spaces from a string?
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the sunlight beams...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-02-20 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (300 votes). Check out past polls.