Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Doubt in assigning hash reference values for Constant pragma declaration ?

by salva (Canon)
on Sep 21, 2007 at 07:08 UTC ( [id://640284]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://640284]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-23 08:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found