[Kc] complex initialization of a state variable in current perl (5.8.7)

Garrett Goebel ggoebel at goebel.ws
Tue May 8 19:10:56 PDT 2007


> use strict;
>
>>> sub foo{
>>>         my $hr if 0;
>>>         BEGIN{
>>>                 $hr = {foo => 23}
>>>         }
>>>         print $hr->{foo},"\n";
>>> };
>>> defined $hr and die "$hr is defined outside of scope";
>>> foo();  # yes indeedy-doo, prints "23\n"

gives:
> Global symbol "$hr" requires explicit package name at foo.pl line 11.
> Global symbol "$hr" requires explicit package name at foo.pl line 11.
> Execution of foo.pl aborted due to compilation errors.

cheers,

Garrett



More information about the kc mailing list