About Me

My photo
London, United Kingdom
SOA tester in London

Wednesday, September 28, 2011

Perl : Array of Hashs

#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

open FILE ,"temp" or die("can not open temp $!");

my $line ;
my ($part1,$part2);
my @AoH=();

while($line = ) {
chomp($line);
my %hasha=();
($part1,$part2) = split(/#/,$line);

my @part1array=split(/\s/,$part1);

%hasha=split(/[=;]/, $part2);

my $datetime="$part1array[1] $part1array[2]";
my $threadname=$part1array[6];

$hasha{"datetime"}=$datetime;
$hasha{"threadname"}=$threadname;

push @AoH, \%hasha;

}
close(FILE);

my $numberofhashes=scalar(@AoH);
print $numberofhashes."\n";
my $hr2=\@AoH;
print Dumper $hr2;

No comments: