Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Mandatory Symbolic References?

by tilly (Archbishop)
on Jan 18, 2011 at 20:11 UTC ( [id://882972]=note: print w/replies, xml ) Need Help??


in reply to Mandatory Symbolic References?

You can do this by assigning a reference to the glob. Here is a sample to get you started.
#! /usr/bin/perl use strict; use vars qw($alpha_state); my %hash = (alpha => {state => "hello\n"}); *alpha_state = \$hash{alpha}{state}; # See that the variable got the value. print $alpha_state; # Show that they are really tied together. $alpha_state = "goodbye\n"; print $hash{alpha}{state};
If you need to set up a number of aliases, you can do no strict 'refs'; in a block and then set them up in there.

Of course you should use these techniques as sparingly as possible. Symbolic references really are a quick way to dig yourself a deep pit.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-19 02:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found