[EMAIL PROTECTED] wrote:

Hi All

Can anyone tell me whether there is any way for declaring an array of
hashes similar to creating array of structure variables in C
programming?

There is a module, Class::Struct, that might be what you want. See `perldoc Class:Struct`.

However, I would simply build the array of hashes as I go:

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my @ArrayOfHashes = ();

for my $count ( 1 .. 10 ){

  my %hash = ();
  for my $key ( 'a' .. 'z' ){
    my $value = rand;
    $hash{$key} = $value;
  }

  push @ArrayOfHashes, { %hash };
}

print Dumper [EMAIL PROTECTED];

__END__


--

Just my 0.00000002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to