Re: $line = <FH> returns incomplete lines





axel@xxxxxxxxxxxxxxxxxxxxxx wrote:

Brian McCauley <nobull@xxxxxxxx> wrote:

axel@xxxxxxxxxxxxxxxxxxxxxx wrote:

The following seems to work.
>>
That is missing the seek() that is needed to reset the EOF flag on MYLOG.
>
> It works without the seek.

I think you were right the first time. It _seems_ to work. My understanding is that it is undefined if Perl's readline() will or will not reset the EOF condition when more data appears in a file.

Right now I can't find a platform on which your code fails but so long as it is officially undefined if it will work without the seek() I'd be inclined not to omit it.

it will work, sort of, but only because you are simply printing the output.

Each time some characters are picked up they are printed.

Yes, that was my point. You rely on the behaviour of the output device to give the false impression that split lines are being reassembled. (Note reassembly of the split lines is the subject of this thread).


If you wanted to do someting else - like selectively print lines by pattern match (as per OP) then it wouldn't work.


I find that it does... a slightly altered version

$line .= $_;

        if (/\n/) {
            $line = '';
        }

Well, yes, of course, if you add the code that reassembles split lines then of course your solution is the same as all the others offered in this thread. (Remember, it is the reassembly of the split lines that is the subject of this thread).


.



Relevant Pages

  • Re: Please stop the personal attacks
    ... what someone says to them the first time. ... Repeating it over and over to them ... will not give them further understanding, and will only make you into a fool ... Steve is usually close behind him with a few ill-chosen ...
    (comp.sys.mac.advocacy)
  • Re: Bad Music
    ... > Understanding is a necessary condition for enjoyment. ... You could read or hear a Chinese poem any number of times, ... > Normally we greet any new piece with partial comprehension. ... > substantial piece of Beethoven he or she heard the first time out. ...
    (rec.music.classical.recordings)
  • Re: REINSTALLING WINDOWS XP ON NEW HARDRIVE
    ... First - your understanding is wrong. ... *If* you want to start over again clean, install ... it will go through on the net just as the first time ... transferred to a new hard disk, use a clone copying tool - what I use ...
    (microsoft.public.windowsxp.general)
  • Re: golf
    ... ITYM: readline ... just so happens that readline (*STDIN) is the same as readline. ... > means the entire file is read and stored the first time the expression ...
    (perl.beginners)
  • Re: The velocity of light going pass a moving train.
    ... errors in understanding and solving the problem. ... transform and one transform without a frame jump ... you should have learnt the first time you made a fool of yourself ...
    (sci.physics.relativity)