#!/usr/bin/perl

use strict;
use warnings;

#use Carp qw(confess);
#use Data::Dumper;
#use Getopt::Std;

use Ernad::Args;
use Ernad::Erimp;
use Ernad::FileInfo;

#my %o;
#&Getopt::Std::getopts('ad', \%o);

our ($impna, $e, $repcode, $in_file);
&Ernad::Args::parse();
if(not $impna) {
  print "I don't see your impna\n";
  exit;
}

$e=Ernad::Erimp->new({'impna'=> $impna, 'verbose'=>3});
my $dir=$e->{'dir'}->{'reports'};

my $o;
foreach my $found (`find $dir -type f | grep sent`) {
  chomp $found;
  my $age=-M $found or die "I don't see the file $found."
  $o->{$age}=$found;
}

foreach my $age (sort {$b <=> $a} keys %$o) {
  my $file=$o->{$age};
  my $issuedate=&Ernad::FileInfo::issuedate($file,'do_strict');
  my $repcode=&Ernad::FileInfo::repcode($file,'do_strict');
  print "$repcode $issuedate\n";
}

__END__;
