in reply to Understanding use and require fully
the values would get lost on each time the required file got hit.
In What's the difference between require and use?
1) do $file is like eval `cat $file`, except the former 1.1: searches @INC and updates %INC. 1.2: bequeaths an *unrelated* lexical scope on the eval'ed code.
It is the unrelated bit; in the eval'ed code lexicals from the including code are not visible. Consider:
# file foo.pl print $var,"\n";
prints foo whilst# requiring code $var = 'foo'; require 'foo.pl';
does not. Also, a file is only required once, so constructs like# requiring code my $var = 'foo'; require 'foo.pl';
won't work as you would expect, since only foo is printed: require on subsequent passes through the loop will just return 1 and not eval the code again.our $var; for $var ( qw(foo bar quux) ) { require 'foo.pl'; }
See also use, require, do or what?
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
---|