Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Concatenation on Variable Name

by toolic (Chancellor)
on Oct 17, 2012 at 17:21 UTC ( #999580=note: print w/ replies, xml ) Need Help??

in reply to Concatenation on Varibale Name

perldoc -q variable
How can I use a variable as a variable name?

Try a hash:

use warnings; use strict; use Data::Dumper; $Data::Dumper::Sortkeys=1; my %var; for ($a = 1; $a <= 10; $a++) { $var{'var_' . $a} = 5 + $a; } print Dumper(\%var); __END__ $VAR1 = { 'var_1' => 6, 'var_10' => 15, 'var_2' => 7, 'var_3' => 8, 'var_4' => 9, 'var_5' => 10, 'var_6' => 11, 'var_7' => 12, 'var_8' => 13, 'var_9' => 14 };

Comment on Re: Concatenation on Variable Name
Select or Download Code
Re^2: Concatenation on Variable Name
by dushyant (Acolyte) on Oct 17, 2012 at 17:46 UTC

    Thanks for the reply and link.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2015-03-30 15:09 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (649 votes), past polls