Read your if statement, you essentially say that if the last modified time of the directory is greater than 2 minutes ago, print "Not modified within last 2 minute". This is clearly not what you want to do. Here is a slightly tidied up version, see also File::stat which is a core module, and Basic debugging checklist.
#!/bin/usr/perl use strict; use warnings; my $modified_within = 2 * 60; my $InputDir = "/home/marto/derpderp"; my $LastModified = (stat($InputDir))[9]; my $CurrentTime = time; if ( $LastModified > ($CurrentTime - $modified_within) ){ print "Modified in last 2 minutes\n"; }else{ print "Not Modified in last 2 minutes\n"; }
In reply to Re: Age of dir in UNIX
by marto
in thread Age of dir in UNIX
by kaka_2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |