in reply to SelfLoader chokes on closed STDIN

Ugh. It's a bug in SelfLoader. Look for the line that says:

croak("$callpack doesn't contain an __DATA__ token") unless fileno($fh);
It should say:
croak("$callpack doesn't contain an __DATA__ token") unless defined fileno($fh);
Notice the "defined" test? In your system (and mine as well), when you close stdin (fileno 0), the C library reuses that file handle for the next usage - which is reading $0, which goes to *main::DATA. So the file number here is 0, which is false, and it croaks. What the author should have said is "check if there is a file number" - not that it's non-zero. (According to fileno, it returns undef if it's not open.)

I suggest opening a bug against it and pointing to this thread. And then you can patch your own if you feel lucky ;-)

Replies are listed 'Best First'.
Re^2: SelfLoader chokes on closed STDIN
by saintmike (Vicar) on Nov 08, 2006 at 17:27 UTC
    Funny, I came to the same conclusion yesterday and got it fixed :).