in reply to Age of dir in UNIX
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Age of dir in UNIX
by kaka_2 (Sexton) on Dec 05, 2013 at 11:08 UTC | |
by marto (Cardinal) on Dec 05, 2013 at 11:15 UTC |