http://qs321.pair.com?node_id=1020557

bdimych has asked for the wisdom of the Perl Monks concerning the following question:

Hi all!

I've accidentally found that "getc" and "sysread" behave differently after "exec":
getc does not get remaining data from the STDIN but sysread does it

echo -n ab | perl -e "print getc; exec 'perl', '-e', 'print getc'"
prints only "a", but
echo -n ab | perl -e "sysread(STDIN, \$b, 1); print \$b; exec 'perl', +'-e', 'sysread(STDIN, \$b, 1); print \$b'"
prints "ab"

why so? where is the "b" in the first case?