On Mon, Aug 10, 2009 at 16:07, Martin Spinassi<martins.li...@gmail.com> wrote:
snip
> It's working I don't have any issues with that :), but I'd like to know
> something...can I make it work with "use strict"?
>
> Using your example would say:
> Global symbol "$home_directory" requires explicit package name at
> test.pl
>
> That appears even if "require" if over "use strict".
snip

The problem here is that the our statement is inside of the lexical
scope of the require.  You need to add

     our ($home_directory, $other_variable, $etc); #preferred method

or

    use vars qw/$home_directory $other_variable $etc/; #needed for
Perl versions older than 5.6

to your code to tell the current scope those variables exist.  Another
option you be to use the fully qualified names:

    print "$main::home_directory\n";

but that defeats the purpose of strict, so don't do that.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to