dch has asked for the wisdom of the Perl Monks concerning the following question:
Now include.pl looks like this: $wibble = "fred"; When I run this I get no output. It looks like 'my' is scoping $wibble to global, but the $wibble = "fred" in include.pl is not evaluated. I suppose I want to implicitly import $wibble from include.pl by using use, but use "include.pl" causes a syntax error. Interestingly if I leave use strict off, then the program prints "fred", as I want. I therefore tried turning off strict for a moment by doing:use strict; my $wibble; do "include.pl"; print $wibble;
but that didn't sort it. It's probably something really obvious, can anyone see what I need to do? I don't want to leave strict off completely. Thanks, dch.no strict "vars"; do "include.pl" use strict "vars";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strict/do question
by shmem (Chancellor) on Nov 24, 2006 at 13:20 UTC | |
by dch (Initiate) on Nov 24, 2006 at 14:20 UTC | |
|
Re: strict/do question
by Tanktalus (Canon) on Nov 24, 2006 at 14:54 UTC | |
by shmem (Chancellor) on Nov 24, 2006 at 16:14 UTC | |
by Tanktalus (Canon) on Nov 24, 2006 at 19:27 UTC | |
by shmem (Chancellor) on Nov 24, 2006 at 20:31 UTC | |
by dch (Initiate) on Nov 24, 2006 at 22:29 UTC | |
by blazar (Canon) on Nov 25, 2006 at 08:36 UTC | |
|
Re: strict/do question
by ikegami (Patriarch) on Nov 24, 2006 at 16:47 UTC | |
|
Re: strict/do question
by Anonymous Monk on Nov 24, 2006 at 12:54 UTC | |
by dch (Initiate) on Nov 24, 2006 at 15:15 UTC | |
|
Re: strict/do question
by Anonymous Monk on Nov 24, 2006 at 13:07 UTC | |
by dch (Initiate) on Nov 24, 2006 at 14:21 UTC |