Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: unsure how to use variable

by JavaFan (Canon)
on Feb 17, 2012 at 16:04 UTC ( [id://954556]=note: print w/replies, xml ) Need Help??


in reply to unsure how to use variable

our $holding1 = "green"; our $holding2 = "blue"; our $holding3 = "yellow"; for (my $count = 3; $count >= 1; $count--) { print do {no strict 'refs'; ${"holding$count"}}, "\n"; }

Replies are listed 'Best First'.
Re^2: unsure how to use variable
by Your Mother (Archbishop) on Feb 18, 2012 at 06:11 UTC

    I know you're just doing your schtick and it’s nice to present a literal answer. Can’t -- that. Still, many, if not most beginner/self-taught hackers arrive at the symbolic references approach on their own. I did and it cost me plenty; slowed me down tremendously for the first year I was slinging Perl and made my code a hateful mess 5 times the size it should have been.

    So, I attach that for the OP. This works. The other suggested approaches are a better way to get your head in the game.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-26 03:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found