Solved 10 minutes later by using:
@list = sort { $filelisthash{$b} <=> $filelisthash{$a} } keys %filelisthash;
Instead of:
foreach $file_num (sort { $a cmp $b } keys %filelisthash) {
push(@list,$file_num);
}
Thanks anyway!! Hope someone finds this helpful...
On 8/7/02 9:17 PM, in article [EMAIL PROTECTED], "Shannon
Murdoch" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a list of 40 or so files that need to be sorted into an array by
> article date (found in first line of each file in the form DD-MM-YYYY).
> I can't figure out how to go about it successfully... Can anyone help me out
> please??
>
> Thanks in advance!
>
> Current method is as follows:
>
>
> use Time::Local;
>
> @list = glob("*.txt"); ## makes an array of files ending in .txt eg 03.txt
>
> foreach $file (@list) { ##find dates...
> open(FEEDBACK,"$file");
> while(<FEEDBACK>){
> chomp($_);
> @feedbackdate = split(/-/,$_); ## eg @feedbackdate = ('07','02','1982')
> $epochseconds = timelocal(1, 1, 1, $feedbackdate[0], $feedbackdate[1]-1,
> $feedbackdate[2]-1900);
> @feedbackdate = (); ##empty the hash for next loop.
> $filelisthash{$file} = $epochseconds;
> last;
> }
> close(FEEDBACK);
> } #end loop
>
> @list = (); ##prepare the list array
>
> foreach $file_num (sort { $a cmp $b } keys %filelisthash) {
> push(@list,$file_num);
> }
>
> print @list;
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]