Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: using main programs variables inside packages

by ant (Scribe)
on Oct 19, 2001 at 12:50 UTC ( #119904=note: print w/replies, xml ) Need Help??


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
  • Comment on Re: using main programs variables inside packages

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://119904]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2023-01-31 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?