in reply to File::Size

TIMTOWTDI, with seek and tell...
use IO::File; ... sub getfilesize { my $filename = shift; my $f = new IO::File $filename or die "File not found"; seek $f, 0, 2; return tell $f; }

Replies are listed 'Best First'.
•Re: Re: File::Size
by merlyn (Sage) on Jan 14, 2004 at 01:56 UTC
    There's no promise that the return value from tell will be the byte offset, only that it can be used with seek to go back to the same place. On some systems, it may need to be "a magic cookie" that has the record and line number encoded opaquely, for example.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      Thanks for the tip. ;-)

A reply falls below the community's threshold of quality. You may see it by logging in.