in reply to Duplicating STDIN
By the time you use FH, STDIN consumed all the data in the file. I would have thought they'd have separate locations in the file, but I guess that doesn't make sense, since output dupes don't.
It works fine if you seek FH back to the start of the file, but then, you could just seek STDIN the same way:
Here it is with STDIN twice:open(FH,"<&STDIN") || die "Error with copying STDIN to FH : $!\n"; while ($inbuf=<STDIN>) { print $inbuf; } seek FH,0,0; while (<FH>) { print $_; } close(FH) || die "Error closing FH: $!\n"; exit;
Both work fine.while ($inbuf=<STDIN>) { print $inbuf; } seek STDIN,0,0; while (<STDIN>) { print $_; } exit;
|
|---|