All pastes #771338 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-12 22:39 UTC
rendered paste body
#!/usr/bin/perl
$spool = "/home/epsas/spool/msg";
sub by_date {
    my @a_tokens = split /\./, $a;
    my @b_tokens = split /\./, $b;

    ## File format : list@dom.date.pid
    my $a_time = $a_tokens[$#a_tokens -1];
    my $b_time = $b_tokens[$#b_tokens -1];

    return $a_time <=> $b_time;

}
#
  if (!opendir(DIR, $spool)) {
                    print "FAIL!!!";
                                    }

                  @qfile = grep (!/^\./,readdir(DIR));
 foreach my $f (@qfile){
	print $f . "\n";
}          
print "\n";
 @qfile = sort by_date (@qfile);

 foreach my $f (@qfile){
	print $f . "\n";
}          
         closedir(DIR);