#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my @all;
while (my $line = <DATA>)
{
next if ($line =~ /[A-Za-z]/);
push @all, [ split (" ", $line) ];
}
# Sort by "In" then "Out" then "Day" increasing
my @ByIn_Out_Day = sort {$a->[1] <=> $b->[1]
||
$a->[2] <=> $b->[2]
||
$a->[3] <=> $b->[3]
} @all;
# Print Sort Result
print Dumper [EMAIL PROTECTED] ;
print "\n\n";
my %group_day_in;
my %group_day_out;
foreach my $i (0 .. $#ByIn_Out_Day)
{
my $day = $ByIn_Out_Day[$i]->[3];
my $in = $ByIn_Out_Day[$i]->[1];
my $out = $ByIn_Out_Day[$i]->[2];
$group_day_in{$day} += $in;
$group_day_out{$day} += $out;
} # ----- end foreach -----
print "Group Day by IN\n";
print Dumper \%group_day_in ;
print "Group Day by Out\n";
print Dumper \%group_day_out ;
__DATA__
ID In Out Day
1 5 2 1
2 4 9 2
3 3 3 2
4 6 7 3
5 5 0 5
6 7 9 3
7 8 9 4
8 6 6 4
--
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>