in reply to 'Our' limits?
you're actually setting the $Foo::var. The our declaration is lexically scoped. The following example could be of some use:package Foo; our $var; $var = 10;
Bar::bar() "sees" the FIRST declaration, whilepackage Foo; our $d; # FIRST $d = __PACKAGE__; package Bar; sub bar { print 'in ', __PACKAGE__, '::bar $d is equal to ', "$d\n"; return; } our $d = __PACKAGE__; # SECOND sub baz { print 'in ', __PACKAGE__, '::baz $d is equal to ', "$d\n"; return; } package main; Bar::bar(); Bar::baz(); __END__ poletti@PolettiX:~/sviluppo/perl$ perl our.pl in Bar::bar $d is equal to Foo in Bar::baz $d is equal to Bar
in the anonymous sub you pass to Foo::top(): the fact that it has the same value of $Foo::d depends on the assignment:Bar::baz()> is in the scope of the second. <p>In your example, you actually access <c>$Bar::d
which makes $Bar::d equal to $Foo::d - ach! :)our($d) = @_;
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
|
|---|