Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Concatenation on Variable Name

by toolic (Bishop)
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 };

Replies are listed 'Best First'.
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]
[Lady_Aleena]: Hello Corion.
[Corion]: Hi Lady_Aleena!
[Lady_Aleena]: Corion, how are things?
[Corion]: Lady_Aleena: Quite good ;) I'm working four days now, instead of five, which helps my mood and my weekends tremendously
[Corion]: My Perl output hasn't recovered, but as $work is still somewhat stressful, I don't think this would be different with a five day workdweek
[Lady_Aleena]: Corion, that is a good thing (TM) 8)
[Corion]: And this evening, I'm actually dusting off some old module of mine and bringing it up to the last version of the library I'm wrapping
[Lady_Aleena]: Updating things can be fun, if there is a better way to do it.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-09-24 18:11 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (274 votes). Check out past polls.