in reply to using main programs variables inside packages
A little confused on about your email, however I'll stick my two cents in.
if you create a variable in X.pm, you can then export that
variable into X.pl.
in X.pm
package X;
vars $database1 = "database";
vars $username1 = "user1";
vars $password1 = "user1";
use vars qw(@ISA @EXPORT @EXPORT_OK);
use Exporter;
@ISA = qw(Exporter Shell);
@EXPORT = qw( $database1 $username1 $password1);
1;
now in X.pl
use X.pm
print "$database1,$username1,$password1";
you can also export sub routines. Hope that helps. Ant
in X.pm
package X;
vars $database1 = "database";
vars $username1 = "user1";
vars $password1 = "user1";
use vars qw(@ISA @EXPORT @EXPORT_OK);
use Exporter;
@ISA = qw(Exporter Shell);
@EXPORT = qw( $database1 $username1 $password1);
1;
now in X.pl
use X.pm
print "$database1,$username1,$password1";
you can also export sub routines. Hope that helps. Ant
|
---|
In Section
Seekers of Perl Wisdom