note
tobyink
<p>Read the [mod://perlfunc] sections about "-X", "stat" and "time".</p>
<code>
use 5.010;
use strict;
my $modified_within = 60 * 5; # 5 minutes
my $size_limit = 1024 * 1024 * 2; # 2 MB
my $file = "/some/file/name";
if ([stat $file]->[9] > time - $modified_within)
{
if (-s $file > $size_limit) {
say "File is recent, and over size limit";
}
else {
say "File is recent, but not over size limit";
}
}
else
{
say "File is not recent";
}
</code>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-757127">
<small><small>
<tt>perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
</tt></small></small>
</div></div>
963189
963189