[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Package shadowing



On Feb 12, Tim Ayers said:

>  package foo;
>
>  my $a = 'foo';

Packages don't matter.

>  sub foo { "foo::a=$a" }

That's not $foo::a.

>  package bar;
>
>  my $a = 'bar';
>
>  sub bar { "bar::a=$a" }
>
>  package main;
>
>  print foo::foo(), "   ", bar::bar(), "\n";

my() variables are not related to any package at all.  $foo::a doesn't
exist.  There is no means of creating a package variable that can't be
accessed from outside its owning package (unless you do some crazy
tie()ing thing).

-- 
Jeff "japhy" Pinyan     japhy@pobox.com    http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource  (my id:  PINYAN)       http://search.cpan.org/
PerlMonks - An Online Perl Community          http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc.   http://www.perlarchive.com/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe