Syntactic Confectionery Delight | |
PerlMonks |
Re^4: reading from a file after a seek isn't working for meby jakobi (Pilgrim) |
on Oct 21, 2009 at 22:46 UTC ( [id://802557]=note: print w/replies, xml ) | Need Help?? |
Thanx for the pointer, almut. That dup & perlio scrap is interesting. But there must be more to it than that, as I don't see any special treatment for STDOUT in the perlio.c scrap (neither for the numeric FD's 0 to 2): I was playing with the scrap below in the meantime. I dupped SAVOUT on STDERR instead / simplifying system to printing / using autoflush / opening STDOUT myself to /dev/tty first: no change. This however is interesting: Changing the name of the handle STDOUT <=> ANYTHINGeLSE manages to act as a toggle for the problem. Furthermore, w/o close, the tell on the STDOUT file pointer at begin prints 19 in the example below (might be due to the handle earlier being a tty, and something didn't quite catch the change to a plain file w/o explicit close?). Any other handle name prints 5 regardless of close or no close. So it looks like we have some hard-coded STDOUT-related magic somewhere in the guts of PERLIO or even lower, with probably STDIN/ERR offering similar peculiarities.
Given that too much in Perl, esp wrt <> and stdio is magic, it's probably a good idea to say strictly outside any possibly dusty corner whose smell is faintly related to something magic. Which in this case might just be the idea of reusing a special handle, and worse, reading from it.
Peter
In Section
Seekers of Perl Wisdom
|
|