Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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
Replies are listed 'Best First'.
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 lurking in the Monastery: (5)
As of 2015-07-28 02:19 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 (251 votes), past polls