package Ernad::Virif; use base 'Ernad'; use Carp qw(confess); use File::Basename; use Ernad::FileInfo; #use Ernad::Report; sub get { my $v=shift; my $repcode=shift // $main::repcode // ''; my $stage=shift // confess "I need a stage here."; my $how=shift // confess "I need know how to list."; my $e=$main::e // confess "I don't see your erimp"; my $rerc=$e->{'report'}->{$repcode} // ''; my $sent_dir=$rerc->{'dir'}->{$stage} // confess "I don't see your stage '$stage'."; my $out={}; foreach my $file (glob("$sent_dir/*")) { if(not $e->{'f'}->is($file)) { $e->echo(__LINE__,"File $file is not a rif, skip."); next; } my $rif=$file; my $shoti=&Ernad::FileInfo::shoti($rif); if(not $shoti) { $e->echo(__LINE__,"File $rif has no shoti, skip."); } if($how eq 'shoti') { $out->{$shoti}=$file; } else { $e->echo(__LINE__,"I have nothing for your how '$how'."); return $out; } } return $out; } sub birth_shoti { my $v=shift; my $repcode=shift // confess "I need a repcode here."; my $sent=$v->get($repcode,'sent','shoti'); my @shotis=sort {$a cmp $b} keys %$sent; return $shotis[0]; } 1;