2007/9/30, Mathew Snyder <[EMAIL PROTECTED]>:
> I'm trying to create an array of hashes with hash names that are simply
> "user1",
> "user2", "user3", etc. How do I use this method when adding one of the hashes
> to the array?
>
> my $user = "user" . $i;
>
> (build hash...)
>
> push @userData, hash
>
Why not create the anonymous hashs?like,
for my $i (1 .. 3) {
push @userData {'user' .$i => 'value1', 'key2' => 'value2' ...};
}
or maybe a HoH is better,as,
my %HoH = ( 'user1' => { key1 => value1,key2 => value2...},
'user2' => { key1 => value1,key2 => value2...}
...
);
If you really want to use a variable as hash's names,you may need to
eval a string,which is not good so.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/