From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ben
Eagle
Sent: 22 January 2007 13:56
To: [email protected]
Subject: Passing Variable from .pl to .pl
> I am trying to break up a script for easy configuration,
>
> So I want to put all my global variables in a file call config.pl
my %advice = ("global variables?" => "Avoid as much as possible.");
>
> And on BuildReport.pl I add
> Require "config.pl";
>
> In strict mode this doesn't work I get error saying I never declared
my variables.
>
> I use our($this, $that);
>
> And still nothing
First, require is executed at run time, i.e. after the variables that
are presumably declared in config.pl have been used. Second, lexical
variables (i.e. 'my') are only visible in the scope in which they are
declared.
>
> Any suggestions??
If you want to do it that way you will need to predeclare your global
variables with 'our' in BuildReport.pl before the require. Then,
assuming no package statements in BuildReport.pl, you could initialise
variables in config.pl like "$::var = ..." instead of "$var = ...".
However this is a pretty fragile solution. There are any number of
config modules on CPAN (e.g.
http://search.cpan.org/search?query=config&mode=all), many of which will
also be available via ppm. Picking one that matches your requirements
would probably be a better solution.
HTH
--
Brian Raven
_________________________________________
The information contained in this e-mail is confidential and solely
for the intended addressee(s). Unauthorised reproduction, disclosure,
modification, and/or distribution of this email may be unlawful. If you
have received this email in error, please notify the sender immediately
and delete it from your system. The views expressed in this message
do not necessarily reflect those of Atos Euronext Market Solutions.
_________________________________________
=================================
Atos Euronext Market Solutions Disclaimer
=================================
The information contained in this e-mail is confidential and solely for the
intended addressee(s). Unauthorised reproduction, disclosure, modification,
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately
and delete it from your system. The views expressed in this message do not
necessarily reflect those of Atos Euronext Market Solutions.
L'information contenue dans cet e-mail est confidentielle et uniquement
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee.
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail
vous parvient par erreur, nous vous prions de bien vouloir prevenir
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre
systeme. Le contenu de ce message electronique ne represente pas necessairement
la position ou le point de vue d'Atos Euronext Market Solutions.
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs