[Israel.pm] Importing variable

Shlomi Fish shlomif at iglu.org.il
Tue Aug 31 08:53:30 PDT 2010

On Tuesday 31 August 2010 13:42:33 Levenglick Dov-RM07994 wrote:
> I am looking for a solution that allows the package scope variables to
> be defined in a different file

You can do that with use or require:

shlomif:~$ cat MyModule.pm
package MyModule;

use strict;
use warnings;

use base 'Exporter';

our $PI = 3.1415926535;

our @EXPORT_OK = (qw($PI));

shlomif:~$ cat test.pl

use strict;
use warnings;

use MyModule qw($PI);

print "PI = $PI\n";

shlomif:~$ perl test.pl
PI = 3.1415926535


	Shlomi Fish

> Best Regards,
> Dov Levenglick
> SmartDSP OS Development Leader

Shlomi Fish       http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html

God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

More information about the Perl mailing list