Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: using main programs variables inside packages

by ant (Scribe)
on Oct 19, 2001 at 12:50 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-23 15:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found