In my limited understanding of this issue, I'd say you need to *read* the data from STDIN first to get the size of the data. Like this:

#!/usr/bin/perl -w use strict; # must use binmode on Windows to get actual byte length of file # otherwise line end processing will ruin our count binmode STDIN; local $/ = undef; my $input = <>; print length($input);

With this scriptlet saved as try.pl and using some html as input:

D:\tmp>perl -0777 -pe "42" try.html | perl try.pl 5409

I think your result from stat() is just applying to the contents of the console buffer you read from, but I am not sure about this, as I never had the idea of using stat() on STDIN, and have no idea currently what this really means.

Update: Zaxo and I performed some experimenting with this on our Linux boxes. For Zaxo (on a 2.4 kernel), stat()ing STDIN always gave 0 in field 7, for me (on a 2.2.16 kernel), it gave different values. We used this code to test:

perl -pe 'BEGIN{$|=1}' /usr/dict/words | perl -lne 'print ((stat STDIN +)[7])'|sort|uniq

So the message seems to be: you can't rely on stat()ing STDIN.

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com


In reply to Re: how to get spool info from NT by clemburg
in thread how to get spool info from NT by physi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.