in reply to RandomFile

To get the file size, you can use the '-s' operator which returns the size of a file (if it has non-zero size)
For example,
$foo = -s "file.txt"; print $foo;
As for hitting the eof, I would say just try again in a new spot.