On Wed, 24 May 2000, Marc Lehmann wrote:
> You must be kidding here!!! Using lexicals on package level is broken??? If
> it is broken, then _why_ is it recommended programming practise in perl (see
> perltoot for example)?
i'm not kidding. i don't understand whay you mean by 'using lexicals on
package level is broken'. i see no problem with that. maybe you could
post an example, your first one, as you said yourself, was broken. here's
a tiny example that is not broken:
% cat MyTest.pm
package MyTest;
my $x = 0;
sub inc_x {
$x++;
}
sub print_x {
print "x=$x\n";
}
print "MyTest loaded\n";
1;
% cat test.pl
for (1..2) {
delete $INC{'MyTest.pm'};
require MyTest;
for (1..5) {
MyTest::inc_x();
MyTest::print_x();
}
}
% perl test.pl
MyTest loaded
x=1
x=2
x=3
x=4
x=5
MyTest loaded
x=1
x=2
x=3
x=4
x=5
are you expecting different results?
and, like i said, i realize that certain modules make assumptions that
they will only be loaded once in the same process and that re-parsing them
can uncover subtle problems. but i still consider such assumptions to be
broken.
- Re: global variables and reparsing (short ... Marc Lehmann
- Re: global variables and reparsing (sh... Perrin Harkins
- Re: global variables and reparsin... Marc Lehmann
- Re: global variables and reparsin... Doug MacEachern
- Re: global variables and repa... Marc Lehmann
- Re: global variables and repa... Doug MacEachern
- Re: global variables and reparsing question (low priori... Gustavo Duarte
- Re: global variables and reparsing question (low p... Marc Lehmann
- Re: global variables and reparsing question (l... Doug MacEachern
- Re: global variables and reparsing questio... Marc Lehmann
- Re: global variables and reparsing que... Doug MacEachern
- Re: global variables and reparsin... Marc Lehmann
- Re: global variables and repa... Doug MacEachern
- Re: global variables and repa... Marc Lehmann
- Re: global variables and repa... Perrin Harkins
- RE: global variables and reparsing question (low priori... Geoffrey Young
- Re: global variables and reparsing question (low p... Marc Lehmann
- [OT] "Tone" on this list Eric Strovink
- Re: global variables and reparsing question (l... ___cliff rayman___
- Re: global variables and reparsing question (l... Doug MacEachern
