Hi,
Having yet another problem which has left me stuck totally...
I have to find a way to return the last three occurances (in terms of nearest date) of a person's name in a particular file (already read into an array) and then ouput this to another file...
Say this is part of my file...
10.01.2003 Sales Jason Jones 24.5
12.01.2003 HR Joey Robert 33.0
02.01.2003 Sales Jason Jones 14.5
17.01.2003 Sales Jason Jones 20.0
28.01.2003 Sales Jason Jones 28.0
10.01.2003 HR Joey Robert 13.0
15.02.2003 HR Joey Robert 38.0
01.02.2003 HR Joey Robert 23.5
The output I need is:
28.01.2003 Sales Jason Jones 28.0
17.01.2003 Sales Jason Jones 20.0
10.01.2003 Sales Jason Jones 24.5
15.02.2003 HR Joey Robert 38.0
01.02.2003 HR Joey Robert 23.5
12.01.2003 HR Joey Robert 33.0
Basically its not only a generalized return of last three recrods, but also by personname as well..
So far I've managed transform the dates into epoch format for comparison and that about it
I've been thinking of hashes but then I have one key (date) to sort by but at the same time must handle the case differenty per person
I'm simply lost as to how to approach the rest of this problem...
Thanks,
Maldini.
Having yet another problem which has left me stuck totally...
I have to find a way to return the last three occurances (in terms of nearest date) of a person's name in a particular file (already read into an array) and then ouput this to another file...
Say this is part of my file...
10.01.2003 Sales Jason Jones 24.5
12.01.2003 HR Joey Robert 33.0
02.01.2003 Sales Jason Jones 14.5
17.01.2003 Sales Jason Jones 20.0
28.01.2003 Sales Jason Jones 28.0
10.01.2003 HR Joey Robert 13.0
15.02.2003 HR Joey Robert 38.0
01.02.2003 HR Joey Robert 23.5
The output I need is:
28.01.2003 Sales Jason Jones 28.0
17.01.2003 Sales Jason Jones 20.0
10.01.2003 Sales Jason Jones 24.5
15.02.2003 HR Joey Robert 38.0
01.02.2003 HR Joey Robert 23.5
12.01.2003 HR Joey Robert 33.0
Basically its not only a generalized return of last three recrods, but also by personname as well..
So far I've managed transform the dates into epoch format for comparison and that about it
Code:
m/^(\d\d)\.(\d\d)\.(\d\d\d\d)\ /; my $mday = $1;
my $mon = $2;
my $year = $3;
my $date_var = timelocal(0,0,0,$mday,$mon-1,$year);
I've been thinking of hashes but then I have one key (date) to sort by but at the same time must handle the case differenty per person
I'm simply lost as to how to approach the rest of this problem...
Thanks,
Maldini.