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.

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"