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; }