saintmike has asked for the wisdom of the Perl Monks concerning the following question:
Now, as you can see, $somevar has been declared properly as a global in main before the function was called, but yet 'use strict' throws a fatal runtime error:package Foo; use strict; sub eval_this { my $code = shift; $code = "package main; \n$code"; eval $code; die ("Error: $@") if $@; } package main; our $somevar = "somevalue"; Foo::eval_this('print $somevar;');
Variable "$somevar" is not imported at (eval 1) line 2. Error: Global symbol "$somevar" requires explicit package name at (eval 1) line 2.Is there a way around this? 'no strict "vars"' would obviously shut strict up, but I would still like strict's variable name checking. Verified with perl-5.10.0.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is strict too strict here?
by jettero (Monsignor) on Jul 11, 2008 at 23:45 UTC | |
|
Re: Is strict too strict here?
by ikegami (Patriarch) on Jul 11, 2008 at 23:52 UTC | |
by saintmike (Vicar) on Jul 12, 2008 at 00:21 UTC | |
by ikegami (Patriarch) on Jul 12, 2008 at 16:21 UTC | |
|
Re: Is strict too strict here?
by tilly (Archbishop) on Jul 12, 2008 at 00:22 UTC | |
|
Re: Is strict too strict here?
by Joost (Canon) on Jul 12, 2008 at 00:27 UTC |