From: "Balint, Jess" <[EMAIL PROTECTED]> > Hi all. As I have known before, "my" declares a variable that is local > to a function. My question, why don't I get an undefined in the > following code example? Shouldn't my @wq be erased after the function > exits? Thanks. Jess > > sub jess{ my @wq = ( 1, 2, 3, 4 ); \@wq; } > > $r = &jess; > > print $r->[0];
No. Keep in mind, this is Perl, not C. Perl does what you need, not what was easiest to implement. The reason is ... my() variables are not alocated on stack, but on heap. Therefore they do not have to be destroyed when you leave the function, but, just like all other values, live as long as there is a reference to them. Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]