I have the following code that I wanna use to see if a file is older than 
today's date ( further along the line if it is I want to delete it but one 
thing at a time)

It's a little rough and has a lot of lines in I use for debugging but if I 
get  an idea if I am in the right direction.
$filename was created ( modified) today)
$filename2 was created (modified) weeks ago

here is the output:

-----------begin output-----------

######################################################

The file you are checking is C:\dosperl\bin\junk2.txt
This file was created today in the else
The file was created today
991353664
Fri Jun  1 00:18:14 2001

######################################################

The file you are checking is F:\Palm\Add-on\diary05202117.17.pdb
This file was created before today in the if
The file is older than today

-----------end output--------------------

------------------------begin code---------

use File::stat;
use time::local;
$filename='C:\dosperl\bin\junk2.txt';
$filename2='F:\Palm\Add-on\diary05202117.17.pdb';
$sb=stat($filename);
$sb2=stat($filename2);
$sb3=localtime;

print "\n######################################################\n\n";

if ($sb->mtime < $sb3)
{
        printf "The file you are checking is %s\n",$filename;
        print "This file was created today in the if\n";
        printf "The file is older than today\n";
}
elsif ($sb->mtime > $sb3)
{
        printf "The file you are checking is %s\n",$filename;
        print "This file was created today in the else\n";
        printf "The file was created today\n";
        printf "%s\n%s\n",$sb->mtime,$sb3;
}
print "\n######################################################\n\n";

#####################

if ($sb2->mtime > $sb3)
  {
        printf "The file you are checking is %s\n",$filename2;
        print "This file was created before today in the if\n";
        printf "The file is older than today\n";
  }
  elsif ($sb2->mtime < $sb3)
  {
        printf "The file you are checking is %s\n",$filename2;
        print "This file was created before today in the else\n";
        printf "The file was created today\n";
        printf "%s is the modified date and %s is the local time", scalar 
localtime $sb2->mtime,$sb3;
}


--------------end code-----------------

Reply via email to