I suspect what you are looking for is a hash of arrays. The following code may get you headed in the right direction:
use strict; use warnings; my %dailyRecords; while (<DATA>) { chomp; next if ! length; my @record = split; # Pull out the data fields # Pull out Date and generate a date stamp my @now = reverse ((localtime ($record[1]))[3..5]); my $dateStamp = join '', map {sprintf '%04d', $_} @now; # Append this record to list keyed by date stamp push @{$dailyRecords{$dateStamp}}, [@record]; } for (sort keys %dailyRecords) { print "Day stamp: $_\n"; my @daysRecords = @{$dailyRecords{$_}}; print "@$_\n" for @daysRecords; } __DATA__ 1149621887 1149623161 NG004193@net.NET 3 820 156 1 +7570249 1149621900 1149623197 NG004193@net.NET 1 648 80 0 +0 1149692376 1149694912 NG004193@net.NET 3 7932259 243 8 +5227944 1149695677 1149695693 Sinkbad@net.net 1 49385 0 0 +0
Prints:
Day stamp: 010600050007 1149621887 1149623161 NG004193@net.NET 3 820 156 17570249 1149621900 1149623197 NG004193@net.NET 1 648 80 00 Day stamp: 010600050008 1149692376 1149694912 NG004193@net.NET 3 7932259 243 85227944 1149695677 1149695693 Sinkbad@net.net 1 49385 0 00
In reply to Re: storing data in a hash
by GrandFather
in thread storing data in a hash
by sunadmn
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |