Does this do what you want?:

#! /usr/bin/perl use strict; use Math::BigFloat; Math::BigFloat->precision(0); sub GetINDirFiles { my @files; my ($path) = $_[0]; opendir (my $directory, $path) or die $!; while(readdir $directory) { push (@files, $_) unless (($_ =~ m/_ACK_/) || ($_ =~ m +/^\./)); } closedir $directory; return(@files); } sub GetOUTDirFiles { my @files; my ($path) = $_[0]; opendir (my $directory, $path) or die $!; while(readdir $directory) { unless ($_ =~ m/^\./) { push (@files, $_) if $_ =~ m/_ACK.xml/; } } closedir $directory; return(@files); } # Main my @range; my $inpath = "./IN/"; my $outpath = "./INACK/"; my $outsuffix = "_ACK.xml"; my $insuffix = ".xml"; # Added by me my $timethreshold = 900; # set time threshold in seconds (900 se +conds equal 15 minutes) my @delindex; my @infiles = &GetINDirFiles($inpath); my @outfiles = &GetOUTDirFiles($outpath); my $index = 0; # index used to get string position in array my $count = @infiles; for (my $x = 0; $x < $count; $x+= 1) { my $name = $infiles[$x]; $name =~ s/$insuffix//; for (@outfiles) { if ($_ =~ m/$name/) { push (@range, $x) } } } my $rangeCount = @range; for (my $x = 0; $x < $count; $x+= 1) { splice(@infiles, $range[$x], 1); } # remove strings my $currenttime = time; # get current time from system (epoch time) foreach my $file (@infiles) { my $fileForTime = "$inpath"."$file"; my $mtime = ( stat $fileForTime )[9]; my $diff = ($currenttime - $mtime); # ignore directories # INSERT SUFFIX AGAIN ($insuffix) # get mtime from file (epoch time) # INSERT SUFFIX AGAI +N ($insuffix) if ($diff > $timethreshold) { print "\n - file " . $file . " in " . $inpath . " direc +tory was created at more than " . Math::BigFloat->new($diff / 60) . +" minutes."; # INSERT SUFFIX AGAIN ($insuffix) # PUT THE ACTION THAT YOU WANT DO HERE!!! } }

NOTE: Change the pathnames!

In reply to Re^7: ignore list of files using readdir function by mtmcc
in thread ignore list of files using readdir function by kaka_2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.