in reply to Use an incrementing counter as a variable
Greetings,
I don't actually get, why you want this. If I read you right, first you are saying you want the counter as a name.
what is the way of using an auto-incrementing counter as a variable name
Then at the end you are saying, you want it as a value, and your code shows you add it as a value.
I will get to know that I have the values "bin_1", "bin_2" etc
So it looks to me line you have to make up your mind about what it is you want. Nevertheless, this solution gives you both the names and the values:
my $counter=0; my %names; while(<>) { $counter++; $names{"bin_".$counter} = "bin_".$counter; } use Data::Dumper qw(Dumper); print Dumper \%names;
So maybe that's a starting point.
Cheers, Sören
Créateur des bugs mobiles - let loose once, run everywhere.
(hooked on the Perl Programming language)
|
|---|