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.

Reply via email to