Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Constant name stored in a string

by WizardOfUz (Friar)
on Jan 28, 2010 at 14:25 UTC ( [id://820157]=note: print w/replies, xml ) Need Help??


in reply to Constant name stored in a string

use constant FOO => 42; my $var = 'FOO'; print &{$var} . "\n"; print defined( &{$var} ) ? "true\n" : "false\n";

Result:

# 42 # true

But this is a bad idea, on many levels ...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-23 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found