in reply to 2-strange side effect with FH

Could you give us examples of what is happenning?

I think that somehow STDIO is confused with eof states, since your are reading after you've written at EOF. Why the code? Beat me with a broom and I still won't know.

Try seek TEMPO, 0, 0; instead of the open, read it to it's end and then immediately reading again - if it still prints out your code then maybe it is something with EOFs. If it messes up on the first read then i dunno...

You should also try this:
use Fcntl qw(O_RDWR O_CREAT); sysopen TEMPO,"c:\\winnt\\temp\\hash.tmp",O_RDWR|O_CREAT or die "$!"; syswrite TEMPO,"aba uba\nniba seba\njak yuk\n"; while (sysread TEMPO, $_, 4096){ print; }

And see if it gives you similar results, and then add sysseek(TEMPO,0,0); between syswrite and while, and see what it does.
These will not solve the problem, but may help identify it. Perhaps you should ask the people at activestate if no one here can find a solution.

Good luck!

-nuffin
zz zZ Z Z #!perl

Replies are listed 'Best First'.
Re: Re: 2-strange side effect with FH
by blm (Hermit) on Oct 22, 2002 at 11:52 UTC

    Here is what happens for me when I run that script without editing

    C:\>"C:\Documents and Settings\blm\Desktop\test.pl" ##open (TEMPO, "<c:\\winnt\\temp\\hash.tmp"); while (<TEMPO>) { print; } <then a lot of blank lines with some "funny ascii characters" interspe +rsed>

    For more information about what the above post indicates might be happening read perldoc seek. It says:

    On some systems you have to do a seek whenever you switch between reading and writing. Amongst other things, this may have the effect of calling stdio's clearerr(3). A WHENCE of 1 (SEEK_CUR) is useful for not moving the file position:

    seek(TEST,0,1);

    Updated: Include the output of the posted sample so everyone can see.

    --blm--