in reply to Re: dos EOF in linux
in thread dos EOF in linux

well, the problem is that the dos eof appears on its own line, so when im processing the lines, heres what happens:
... open INPUT_HANDLE .... or die ... while ( my $line = <INPUT_HANDLE> ) { chomp $line; last if my_eof_test($line, \*INPUT_HANDLE); process_line($line); } close(INPUT_HANDLE); ...
i feel that i need this test because otherwise, the line that contains just the EOF will read properly, because there it is data, even though its the DOS EOF. because the read is true, we get in the while loop, and the line containing just EOF gets sent to process_line(). am i missing something here?

Replies are listed 'Best First'.
Re: Re: Re: dos EOF in linux
by demerphq (Chancellor) on Jan 21, 2003 at 19:09 UTC
    As far as I know this isnt an issue. But im a win32 user. :-)

    And may I point out that

    while ( my $line = <INPUT_HANDLE>) {
    is not the same as (excepting the variable used)
    while ( <INPUT_HANDLE> ) {
    I believe that should read
    while ( defined ( my $line= <INPUT_HANDLE> ) ) {
    But personally I dont see the point. You shouldnt be afraid of using $_.

    --- demerphq
    my friends call me, usually because I'm late....

Re: Re: Re: dos EOF in linux
by Mr. Muskrat (Canon) on Jan 21, 2003 at 18:13 UTC
    It shouldn't matter but if you are worried about processing the EOF marker, try this...

    ... open INPUT_HANDLE .... or die ... while ( my $line = <INPUT_HANDLE> ) { chomp $line; process_line($line); last if eof(INPUT_HANDLE); } close(INPUT_HANDLE); ...