Rajesh Dorairajan wrote:
Can someone explain how does one pass a parameter to a Perl Module? To
illustrate suppose I've My::Module

package My::Module;

BEGIN
{
  $scalar = $input;
}

use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = ($scalar);

In the above script is there anyway to pass the $input variable to the
package My::Module from the calling script? Please excuse me if the code is
horrible, just trying to simplify what I want ;)

TIA

Rajesh



Suppose you are calling this from a script say script.pl

in script.pl put
BEGIN {
  $GLOBAL::input="THIS IS PASSED TO THE MODULE";
  require My::Module;
}



and in the package put
$scalar=$GLOBAL::input;


I am not very sure if this a "good" way of doing it but works.
And BTW you can not do *use* My::Module , You will have to do *require* My::Module






Ram





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to