Online Shopping : Computers : Programming : Languages : Perl

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

1 of 1 people (100%) answered Yes
Recently 1 of 1 people (100%) answered Yes


I have a variable in a new function in a Perl module, I want that varaible to retain its value.

Apr 14th, 2009 04:02
roan mke, Vincent Milette, Kunal Kapoor,

In your perl-module, you must export the variable. That way, you will be
able to use it 
If you don't know how to export the variable here is the way your module after the package name...
use Exporter;
use vars qw(@ISA @EXPORT $VERSION);
$VERSION = 1.00;
@ISA = qw(Exporter)
@EXPORT = qw($var); #export the var to other module or script including
this module
use vars qw ($var); # give the possibility to use the var in the module
By exporting the var this way it is easier to create a config file for
your program...I do it 
like that all the time
For further help, see:
There is a chapter about Exporting module
There is also other way to do what you want...because with
perl..."There's More Than 
One Way to Do It"
Vincent M.