in reply to Counting the size of STDIN

The traditional way that I would find the size of a file (apart from an existing function that would do it for me) is to:

  1. Move “zero bytes away from here” on a filehandle to obtain my present location in bytes. (“n”)
  2. Move “zero bytes back from end-of-file” to obtain the file’s present length.
  3. Move “n bytes away from start-of-file” to go back to where I was.

The trouble with this, in the particular case of STDIN, is that such a filestream is usually a stream, and therefore not “positionable.”   If it is a pipe (and you don’t know that until runtime), it has no set “size” at all.   You just pump from it until the well eventually runs dry.