SPUG: geting variables from a 'required' file
Brian Ingerson
briani at activestate.com
Mon May 14 16:00:45 CDT 2001
Dan Ebert wrote:
>
> I am wanting to set some global variables in a required file (so I can use
> different values on different servers without editing the main script
> code.) This code works fine with perl 5.6:
>
> use strict;
>
> our ($var1,$var2);
> require 'vars.pl';
>
> print $var1, "\t", $var2, "\n";
>
> but not with 5.005 and if I use 'my' instead of 'our' the values of $var1
> and $var2 are NULL. Is there a way (with 5.005) to declare the variables
> so this will work and 'use strict' won't complain?
use vars qw($var1 $var2);
In fact, until we can get everyone to finally abandon 5.005 (which is
*old*) you pretty much need to avoid using 'our' for shared code.
Brian
--
perl -le 'use Inline C=>q{SV*JAxH(char*x){return newSVpvf
("Just Another %s Hacker",x);}};print JAxH+Perl'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list