First off, despite the fact that Win32 uses "\" as a
path separator, I strongly recommend using forward slash "/"
as your path separator. Just to easy to mess up the escaping
of the backslash character. Not saying you are necessarily
doing this, but it is very error prone.
That being said, try modifying your code to the following
and run again:
use Cwd; # at the top of your code where you place your "use"
statements
my $local_dir = cwd();
$local_dir =~ s#\\#/#g;
foreach $xFile (@xFileList) {
$x = "$local_dir/$xFile";
die "*** Error: '$x' does not exist\n" unless -e $x;
$xsize = (stat($x))[7];
print "\nFile tested is $x; size was $xsize.\n";
if ($xsize > 0) {
print " WILL process file $xFile (size=$xsize) ...\n";
} else {
print " Will NOT process file $xFile (size=$xsize) ...\n";
};
};
--
Mike Arms
-----Original Message-----
From: Laurie Vien [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 06, 2004 12:43 PM
To: 'Dirk Bremer (NISC)'; [EMAIL PROTECTED]
Subject: RE: Help getting file size (sheesh) ...
I put in some prints to better see what's happening. Here's the code
and the results:
foreach $xFile (@xFileList) {
$x = "$local_dir\\$xFile";
$xsize = (stat($x))[7];
print "\nFile tested is $x; size was $xsize.\n";
if ($xsize > 0) {
print " WILL process file $xFile (size=$xsize) ...\n";
} else {
print " Will NOT process file $xFile (size=$xsize) ...\n";
};
};
Results:
File to be tested is
\\GADGET\SAP$\Test\ship_confirm\bj_so_0083140631.xfr; size was .
Will NOT process file bj_so_0083140631.xfr (size=) ...
...
Same output for every file in the directory (16 of them), even though 5
of the files are not empty.
Laurie
-----Original Message-----
From: Dirk Bremer (NISC) [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 06, 2004 2:31 PM
To: Laurie Vien; [EMAIL PROTECTED]
Subject: Re: Help getting file size (sheesh) ...
Laurie,
I suspect that you are not using a fully qualified filename. The
filename should include the full path to the file.
Dirk Bremer - Systems Programmer II - ESS/AMS - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471
[EMAIL PROTECTED]
www.nisc.cc
----- Original Message -----
From: Laurie Vien
To: [EMAIL PROTECTED]
Sent: Wednesday, October 06, 2004 13:18
Subject: Help getting file size (sheesh) ...
I'm trying to just determine the size of a file before I decide whether
to process it. In the following code, $size always comes out null:
foreach $xFile (@xFileList) {
$size = (stat ($xFile))[7];
if ($size gt 0) {
print " Found file $xFile with size $size, so WILL push it
...\n";
} else {
print " Found file $xFile with size $size, so will NOT push
it ...\n";
};
I also tried $size = (-s _) instead of using "stat", but got the same
result--$size comes out null. What am I doing wrong?
Thanks--
Laurie
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs