Beginner wrote:
>
On 6 Mar 2007 at 6:08, Jeff Pang wrote:

Is it possible to send an variable (through the env or as an
argument, or ....) so I can use the variable $dir from the module test.pl to set the variable $vardir in param.pl. ??

Yes you can.
You may declare the vars wanted to be shared in the module as package variable using 
Perl's "our" statement.

$ cat test.pl use strict;
our ($path1,$path2);
require "param.pl";
print("path1 $path1\n");
print("path2 $path2\n");

$ cat param.pl #!/usr/bin/perl
use strict;
my $basepath = "/var/tmp";
my $vardir = "dir";
our $path1="$basepath/$vardir/path1";
our $path2="$basepath/$vardir/path2";

1;

Is the 1; required here? I thought it was only needed in packages. Am I
mistaken?

You mean modules? Everything written in Perl is in one package or another.

Any call to 'require' causes the program to die if the result of executing the
required file isn't true. A line like 'use Module' is essentially a call to
'require Module.pm' with some extra stuff around it.

Rob


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to