FAQ
I tried but am using AS 5.6.0 under w2k. The first time it
complained because I did not have the file setup correctly and it died.
After correcting that it worked.

This is the code:

use File::stat;
my $firstFile = 'd:/Currwrka/00CommonPerl/03aaplxxx/aapl001.pl';
my $secondFile = 'd:/Currwrka/00CommonPerl/03aaplxxx/aapl002.pl';

my $file1 = stat($firstFile);
my $file2 = stat($secondFile);

if ($file1->size > $file2->size) {
printf "file1 greater than file2";
}else {
printf "file2 greater than file1";
}

Wags ;) ps R you running with warnings? strict?

-----Original Message-----
From: Brian McGraw
Sent: Friday, January 03, 2003 11:10
To: beginners@perl.org
Subject: Comparing file sizes


Hello all.

I'm trying to compare the size of two files in a script. I know I can open
them, feed each into an array, and compare the number of lines, but that
seems silly and inefficient. I tried using File::stat in the following
manner:

$file1 = stat($firstFile);
$file2 = stat($secondFile);

if ($file1->size > $file2->size)
{
blahblahblah;
}

Everytime the script gets to these lines, the stat function fails, and the
program exits. Am I doing somthing wrong? I'm using perl 5.8.0 on Redhat
8.0.

Thanks for the help,
Brian


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedJan 3, '03 at 7:10p
activeJan 3, '03 at 7:23p
posts2
users2
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase