sub check_sequence { my $switch_name = shift; my $tmp = 0; my $archive_dir = $dirlst{$switch_name}; opendir(DIR, "$archive_dir") or die ("Can't open $archive_dir\n"); foreach my $infile (readdir(DIR)) { next unless $infile =~ /NOK/; $tmp_seq = (split(/_/, $infile))[2]; ($seqno = substr($tmp_seq,2,4)) =~ s/^0//g; push (@file_lst, $seqno) if $seqno !~ /$tmp/; $tmp = $seqno; print "$seqno\n"; } closedir(DIR); @sortlst = sort { $a <=> $b } @file_lst; $curseq = $sortlst[0]; for (my $i =1; $i < @sortlst; $i++) { $nextseq = $sortlst[$i]; $curseq++; if ($curseq ne $nextseq) { while ($curseq ne $nextseq) { push(@missing, $commseq); print ("Found missing file sequence $curseq - $nextseq\n"); $curseq++; } } $curseq = $nextseq; } }