Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

negative stat value

by Anonymous Monk
on Aug 23, 2001 at 20:39 UTC ( [id://107391]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use File::stat to get the file size of a file like so:
my $file = "c:/autoexec.bat"; my $fStats = stat($file); print "Size is: " . $fStats[7]. "\n";
This works fine on small files, but any file teh exceeds the 32-bit integer has a negative value for size. Does anyone know how for me to get the actual value of the file, other than a DOS DIR? I don't want to do a DOS DIR and parse the output.

Edit Masem 2001-08-23 - Added CODE tags

Replies are listed 'Best First'.
Re: negative stat value
by jlongino (Parson) on Aug 23, 2001 at 21:24 UTC
    Just a quick suggestion. BTW, I don't have any files that large to test, so you might encounter the same problem with this. But give it a try:
    my $size = -s "filename"; print $size;

    If the code and the comments disagree, then both are probably wrong. -- Norm Schryer

      Unfortunately, this does retrieve the same results as STAT, but a positive is I found another way to get a files size. Does anyone know if stat uses a Binary or ASCII representation?
(tye)Re: negative stat value
by tye (Sage) on Aug 24, 2001 at 11:27 UTC

    You need to build your copy of Perl with "large file support" enabled. This causes Perl to use 8-byte integers for items related to file size instead of 4-byte integers. This is only available on when building Perl on certain operating systems.

    My overly quick search turned up:

    Perl can be built to understand large files (files larger than 2 gigabytes) on some systems. To do so, Configure can be run with -Duselargefiles.
    which should get you started.

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://107391]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-25 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found