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

While this doesn't address the mystery of a truncated file output - try the following with the history.txt file:
perl -n00 -e 'print $1,"\n" if /Overall Grade.*?([\d.]+%)/ms' history. +txt

That should produce

95.9%

i.e. the contents of line 32.

See perlrun for command line switches, perlre for regular expressions.

<update>

Using a regular expression here is more reliable, since the line number where the sought information is stored arguably is more prone to changes than the format of the retrieved file.

</update>

--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 03, 2007 at 00:17 UTC
    It works! I hope to get it all working in perl, but for now I'm happy with this shell script:
    #!/bin/bash perlgrade #perlgrade is the name of my grade downloading script perl -n00 -e 'print "French: $1","\n" if /Overall Grade.*?([\d.]+%)/ms +' /home/jesse/Desktop/grades/french.txt perl -n00 -e 'print "Math: $1","\n" if /Overall Grade.*?([\d.]+%)/ms' +/home/jesse/Desktop/grades/math.txt perl -n00 -e 'print "Biology: $1","\n" if /Overall Grade.*?([\d.]+%)/m +s' /home/jesse/Desktop/grades/biology.txt perl -n00 -e 'print "Band: $1","\n" if /Overall Grade.*?([\d.]+%)/ms' +/home/jesse/Desktop/grades/band.txt perl -n00 -e 'print "English: $1","\n" if /Overall Grade.*?([\d.]+%)/m +s' /home/jesse/Desktop/grades/english.txt perl -n00 -e 'print "World History: $1","\n" if /Overall Grade.*?([\d. +]+%)/ms' /home/jesse/Desktop/grades/history.txt