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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |