in reply to Re: Perl doesn't read whole file
in thread Perl doesn't read whole file

Thanks for responding. The file is UTF8 encoded, but I'm not sure what my terminal is set to. However, everything works for english (which is also UTF8). Your script just returns "Use of uninitialized value in print at thing line 8, <GRADE> line 1."

Replies are listed 'Best First'.
Re^3: Perl doesn't read whole file
by shmem (Chancellor) on Dec 02, 2007 at 23:31 UTC
    Your script just returns "Use of uninitialized value in print at thing line 8, <GRADE> line 1."

    which probably means the file is zero bytes long (i.e. empty) <update> but more likely it means I've made a silly mistake. See ikegami's note below. </update>

    update: Oh, and another point: always check the return value of functions; the script is more aptly written as

    #!/usr/bin/perl -w open(GRADE, "/home/jesse/Desktop/grades/history.txt") or die "Can't open '/home/jesse/Desktop/grades/history.txt': $!\n" +; while ($test = <GRADE>) { ; # do nothing } print $test; # print last line close GRADE;

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      You raise a good point about the return value of functions - I was just lazy. The file is not empty. If I look at its properties, I see that it has 2,638 Bytes. Using the shell, I tried cat /home/jesse/Desktop/grades/history.txt. It's result was "ationslER 6", part of the fragment my script produces.