Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: variable constructs that I do not understand

by wink (Scribe)
on Sep 06, 2011 at 21:42 UTC ( #924470=note: print w/ replies, xml ) Need Help??


in reply to variable constructs that I do not understand

Perl allows you to use the value of one scalar as the identifier for another. Rarely is it a good idea, but occasionally it is useful.

$var = 'foo'; $foo = 'bar'; print $var; # Will print "foo" print $$var; # Will print "bar"
Also, you can use curly braces around a variable when it might be confusing to the compiler what you mean.
$foo = 'foo'; print "$food"; # Will print nothing (no scalar $food is defined) print "${foo}d"; # Will print 'food' as expected


Comment on Re: variable constructs that I do not understand
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2015-07-30 09:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls