on 1/25/02 10:41 AM, [EMAIL PROTECTED] purportedly said: > #!perl -w > # this is dog > use strict; > my $foo = 10; > require 'cat'; # a perl script > __END__ > > #!perl -w > # this is cat > use strict; > my $foo = $::foo; > print defined($foo) ? $foo: 'undefined',"\n"; > __END__ >
I just remembered: variables declared with my() are considered private to the package and cannot be accessed even by their full invocation: $package::foo ($::foo is shorthand for $main::foo). If you remove the my() declaration in dog and call use vars() as was previously recommended, you get around this as you are declaring $foo as a package global, but that's really a kludge and you should really not redeclare $foo in cat. It's a useless call and could confuse the code later on. Keary Suska Esoteritech, Inc. "Leveraging Open Source for a better Internet"
