in reply to Parental Variables
Library:
Program:package Subs; our $Foo = 3; sub foo { $Foo++; } 1;
If you want to then export the symbols &Subs::foo and $Subs::Foo to the main program, you add a little stuff to your library. The Exporter module helps you export certain symbols into the "parent" or calling scope.use Subs; Subs::foo(); print $Subs::Foo, "\n";
Library:
Program:package Subs; BEGIN { use Exporter; our @ISA = qw(Exporter); our @EXPORT = qw($Foo &foo); } our $Foo = 3; sub foo { $Foo++ } 1;
For a lot more detail on this process, and other features, check out perlmod (or type perldoc perlmod at your console).use Subs; foo(); print $Foo, "\n";
--
[ e d @ h a l l e y . c c ]
|
|---|