Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Dereferencing simple variable

by akho (Hermit)
on Apr 01, 2009 at 13:45 UTC ( #754702=note: print w/replies, xml ) Need Help??

in reply to Dereferencing simple variable

It looks like you are trying to use variable names stored in strings? This is not a very good thing to do, and you should probably reconsider.

However if you insist on doing that, you should look into symbolic references (see perlref). They only work with package variables, however (not those created with my). This seems to work:

my $test = "help"; our $help = 1; no strict 'refs'; if(defined($$test)){ print "defined\n"; };

Replies are listed 'Best First'.
Re^2: Dereferencing simple variable
by chrishowe (Acolyte) on Apr 01, 2009 at 14:03 UTC
    I'm going to try and reconsider. As above, hashes are most proably the way forward!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2016-10-24 06:39 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (303 votes). Check out past polls.