narainhere has asked for the wisdom of the Perl Monks concerning the following question:
and a file 'env.pl' which containsuse strict; use warnings; require "env.pl"; foreach my $file("env.pl","env1.pl") { $main::var="default"; require "${file}"; print "\nIn $file var is : $main::var\n"; }
Another file 'env1.pl' which contains$var="env"; 1;
All in the same folder.Now If I run the script I get the o/p$var="env1"; 1;
But If I comment Line 4In env var is : default In env1 var is : env1
in my script It works fine. So Why is that If read $main::var then modify it then read it again from the same file it's value is not changing??require "env.pl"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with require and default package
by Corion (Patriarch) on Dec 21, 2007 at 10:04 UTC | |
by narainhere (Monk) on Dec 21, 2007 at 10:17 UTC | |
by cdarke (Prior) on Dec 21, 2007 at 11:07 UTC | |
by olus (Curate) on Dec 21, 2007 at 12:01 UTC |