> > Lexicals aren't in the symbol table. > > my $foo; > > *can't* be accessed as $pack::foo, because it isn't IN a package. > > true. > > > Locals, on the otherhand, *have* to be package variables that can > > be tracked by $pack::foo syntax. So how can > > my @bar; > > allow > > local $bar[2]; > > to localize an element of @bar which isn't traceable through a > > package name? It obviously works, but I don't see *how*. > > there is no package variables in Perl, only global or lexical.
Not so -- ALL package variables in Perl *are* global, but likewise all global variables in Perl are package vars. Even $_ is technically $main::_ so that $_ = 'foo'; package bob; print $main::_."\n"; prints "foo" and the newline. > local doesn't work on what you refer to as package or my-variable. package variables aren't my() variables -- my()'s are lexical. package vars are in some package...though you can say package; to make no package the default, that just means you have to specify one. Thus, package; $x = 1; is an error, just as if strict vars were in effect, whereas package; $foo::x = 1; is fine. > it works on the stack. What stack? Not the function call stack..... You mean there's a stack for symbol table entries? NOW we're getting somewhere! That makes sense, and I hope it's true. > all variables are on the stack whether it's global or lexical (there > are different stack for different thing of course). local localizes > the variable(puts it on the stack), the value is pop off the stack > after the block exit(no matter how it exit) so the original value is > retain. that's *how* :-) And that answer makes me happy. Can someone confirm? __________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]