Not sure if this is the "best" way to do it, but change dog to

#! perl -w
# this is dog
use strict;
use vars qw($foo);
$foo = 10;
require 'cat'; # a perl script
__END__



> Hi,
> 
> How can I export $foo to 'cat' ?
> The following doesn't work. $foo in cat is undefined.
> I tried "local $foo" in dog. It asks for a package name, and that doesn't work
> either in cat.
> 
> Thanks.
> 
> MacPerl 5.2.0r4
> 
> #!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__
> 

Reply via email to