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

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://754702]
help
Chatterbox?
[marioroy]: Today, wanted to revisit running parallel Re: Crash with ForkManager on Windows. I tried running on Cygwin for comparison.
[marioroy]: Running parallel on Cygwin feels like running on Unix ;-)
[marioroy]: Fortunately, Strawberry Perl v5.26 runs well.
[karlgoethebier]: marioroy: He! Magic Mushrooms was a talk in the CB some days ago ;-)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-09-23 16:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (272 votes). Check out past polls.

    Notices?