Alex Harris wrote:
> 
> Ok so I'm REALLY REALLY a newbie and this next question is going to sound
> like "where's the spoon" so you can feed me but...
> Here's my code and the error I got.  I know it means I'm suppose to include
> something but I'm not sure what.

You are making this _way_ too complicated.  The stat() function returns
the mtime in the number of seconds since the epoch.  You then convert
that to a string using ctime() and _then_ parse the date from the string
to a number to compare it to another date.


> use File::stat;
> 
>    use Time::localtime;
>    $date_string = ctime(stat($file)->mtime);
>    $date_string2 = ctime(stat("zzp2.txt")->mtime);
> 
>    print "$date_string   $date_string2\n";
> 
> $date1=&ParseDate($date_string);
> $date2=&ParseDate($date_string2);
> $flag=&Date_Cmp($date1,$date2);
> if ($flag<0) {
>    print "date 1 is earlier\n";
> } elsif ($flag==0) {
>    print "the two dates are identical.\n";
> } else {
>    print " date2 is earlier\n";
> }

#!/usr/bin/perl -w
use strict;

# Get the mtime from two files
my $date1 = (stat $file)[9];
my $date2 = (stat 'zzp2.txt')[9];

print scalar $date1, '   ', scalar $date2, "\n";

if ( $date1 < $date2 ) {
    print "$file is older than zzp2.txt.\n";
    }
elsif ( $date2 < $date1 ) {
    print "zzp2.txt is older than $file.\n";
    }
else {
    print "the two dates are identical.\n";
    }

__END__


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to