in reply to Re^8: Extracting Data from a second line
in thread Extracting Data from a second line

So, what is the answer then? When reading DATA, do we continue to manually count the characters and use that? Or do we use a number that we know will be sufficient (1000000 or something similar) but is guaranteed too big? These are more rhetorical questions than anything. I would just like a way to find the size of DATA, programmatically.
  • Comment on Re^9: Extracting Data from a second line

Replies are listed 'Best First'.
Re^10: Extracting Data from a second line
by ikegami (Patriarch) on Feb 16, 2006 at 20:07 UTC

    If you wish to know the size of DATA, in characters, use the following. It will work on with all line terminators and will all encodings.

    $size_of_DATA = read(DATA, $buf='', -s DATA);

    It's safe to use -s FILE because the number of characters in a file should never be bigger than the number of bytes in a file.