in reply to Re: Two Questions on "my"
in thread Two Questions on "my"

I'm not sure if I've got some sort of mental filter that spots these, or if it's a commonly encountered problem, but this is the third time in a week someone has asked this question.

The answer is that my has both a compile- and a run-time effect. The compile-time effect allocates space for the variable and lets it pass strict. The run-time effect initializes the variable. If you conditionalize the initialization you have, in effect, a static variable; one that retains its value beyond scope exit.

I've explained it in more detail, with a documentation reference, here, and it has been covered in a thread here.

Replies are listed 'Best First'.
Re: Re: Re: Two Questions on "my"
by Dr. Mu (Hermit) on May 24, 2004 at 06:29 UTC
    Yup. This is the kind of stuff that makes my Python buddies wince when they regard my affinity for Perl. But their desks are tidy. Mine is messy. There's obviously a connection.

    Thanks, Somni!