On Jul 29, 2008, at 8:42 AM, Mark Mielke wrote: > Peter Scott wrote: >> This very nearly qualifies as an easter egg. Inspect the following: >> >> perl -e 'close STDIN; open STDIN, "<", \$x; print <>' >> >> Guess what it does. Run it. See if you were right. >> >> Bugworthy? I don't know; maybe, that's why I mention it here. But >> it had >> some entertainment value for me today. >> > > +1 for weird. :-) > > Do you have an explanation for why it does what it does? :-) Yes. <> is reading from stdin in C (file descriptor 2) which will be what was first opened after closing STDIN. The open STDIN, "<", \$x causes the PerlIO module to be loaded, so the first file opened is PerlIO.pm What you see in the output is what is after the __END__ in PerlIO.pm Graham.Thread Previous | Thread Next