in reply to length of a file

If it's a string or a filehandle, you can do
my $size = (stat($file))[7];