Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^7: ignore list of files using readdir function

by poj (Priest)
on Jul 23, 2013 at 12:37 UTC ( #1045847=note: print w/ replies, xml ) Need Help??


in reply to Re^6: ignore list of files using readdir function
in thread ignore list of files using readdir function

In that case a simpler more direct approach might work for you

#!perl use strict; my $inpath = "/AAA/BBB/CCC/IN"; my $outpath = "/AAA/BBB/CCC/OUT"; # check inpath files less than 60 mins # and more than 15 mins old my $min_age = 0.25/24; # 15 mins in days my $max_age = 1.00/24; # 1 hour in days my $count =0; my $ignore=0; print "Scanning in dir $inpath .. \n"; opendir DIR, $inpath or die $!; for (readdir DIR){ # skip if not a file next unless (-f "$inpath/$_"); # filter on age my $age = -M "$inpath/$_"; if ( ($age > $min_age) && ($age < $max_age) && ( !/_ACK_/ ) ){ # build outfile name (my $outfile = $_) =~ s/(\.xml)$/_ACK$1/; # check outfile exists if (-e "$outpath/$outfile"){ print "$_ => $outfile exists\n"; } else { print "$_ => $outfile does not exist\n"; } ++$count; } else { ++$ignore; } } closedir DIR; print "$count files checked - $ignore files ignored\n";
poj


Comment on Re^7: ignore list of files using readdir function
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045847]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2015-07-01 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (19 votes), past polls