Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Pearls (not really) of Perl programming

by hardburn (Abbot)
on Nov 24, 2004 at 18:45 UTC ( #410210=note: print w/ replies, xml ) Need Help??


in reply to Re: Pearls (not really) of Perl programming
in thread Pearls (not really) of Perl programming

This is at the beginning of a script that I must have written shortly after I learned about use strict.

I think everyone goes through a phase like that. I certainly have code with "global lexicals" from my early use strict days.

$start =~ s/^\s+//g;

Is there a reason for the /g?

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.


Comment on Re^2: Pearls (not really) of Perl programming
Select or Download Code
Re^3: Pearls (not really) of Perl programming
by revdiablo (Prior) on Nov 24, 2004 at 19:08 UTC
    Is there a reason for the /g?

    Since the code is several years old (perhaps 5 or 6), I don't remember exactly. But the most likely explanation is that I used to be a pretty bad cargo-cult programmer.

Re^3: Pearls (not really) of Perl programming
by exussum0 (Vicar) on Nov 25, 2004 at 00:15 UTC
    An obvious reason. Habit. I'm always typing ~s/.../.../g out of habit, never thinking of doing a replace only once.

    ----
    Then B.I. said, "Hov' remind yourself nobody built like you, you designed yourself"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (12)
As of 2014-04-23 09:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (541 votes), past polls