Check file date before getting folder path

shragi used Ask the Experts™
Hi - I just asked the below question in another ticket, but i want some extension to it.

I have a requirement where I want to find whether any files are in the given folder.
So I listed all the folder paths in a text file and want to send that file as input to perl script
now perl script reads each line and gets each folder path and should check whether it contains any files
if it contains any files then it should print that folder path into the output file.
that's my original question but now I want to print the output file only if the file contained in the folder is one day old.

Inputfile.txt is as below

f1 has one file that has modified date from 3 days go, but f2 has file that is created like an hour back.
so when I run the perl script I should only get

use strict;
use warnings;
use Pod::Usage;
use Getopt::Long;
use Time::Piece;

my $helpme = 0;
my $man = 0;

my $inputFileName = 'C:\\temp\\input.txt';
my $outputFileName = 'C:\\temp\\output.txt';
my $fileModifiedDate = '';
my $errorcode = 0;
my $DEBUG=0;

if(exists $ENV{DEBUG}) {
	$DEBUG = ($ENV{DEBUG} eq "") ? 0 : $ENV{DEBUG};

GetOptions('help' => \$helpme, 'man' => \$man, 'infile=s' => \$inputFileName, 'outfile=s' => \$outputFileName) or pod2usage(2);

pod2usage(1) if $helpme;
pod2usage(-verbose => 2) if $man;

die 'No input file name specified!' unless $inputFileName;
die 'No output file name specified!' unless $outputFileName;

open(INFILE, '<', $inputFileName) or die "Could not open input file: $!";
open(OUTFILE, '>', $outputFileName) or die "Could not open/create output file: $!";

while( my $dir = <INFILE>) {
	chomp $dir;
	opendir DIR, $dir or die "could not open dir $dir: $!";
	if (grep { $_ ne '.' and $_ ne '..' } readdir DIR) {
					print OUTFILE $dir, "\n";
        closedir DIR;

close INFILE;
close OUTFILE;

exit $errorcode;

Open in new window

so now I would like to add condition something like below
$fileModifiedDate = POSIX::strftime("%Y-%m-%d %H:%M:%S", localtime(( stat filename )[9]));
            if($fileModifiedDate < currentDate -1)
                              print OUTFILE $dir, "\n";

can you guys please help me with the missing piece.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Top Expert 2015
if (grep { $_ ne '.' and $_ ne '..' and  -M "$dir/$_" > 1 } readdir DIR) {

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial