http://qs321.pair.com?node_id=640284


in reply to Doubt in assigning hash reference values for Constant pragma declaration ?

use constant A => $hash;
is evaluated at compilation time, before
my $hash = { 'a' => 2 };
has been executed.

Yo can use a BEGIN block to make the assignment at compile time:

my $hash; BEGIN { $hash = { 'a' => 2 } } use constant A => $hash;
Or also:
my $hash; use constant A => $hash = {'a' => 2};

Replies are listed 'Best First'.
Re^2: Doubt in assigning hash reference values for Constant pragma declaration ?
by gube (Parson) on Sep 21, 2007 at 10:08 UTC

    The above given information and example was very nice.

    Thanks
    Gubs