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

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}

Replies are listed 'Best First'.
Re^4: Perl doesn't read whole file
by colonelcrayon (Novice) on Dec 02, 2007 at 23:56 UTC
    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.