Okay, I finally got it to work. With a bit of help from you guys, and some help from my teacher.

I needed to read the "End of Record"...Bleh.


Thanks everyone!! :)
# !perl/bin/perl -w #Lab 7a #XXXX XXXX #My full name...Yeah. #Calculates grade averages open (INPUT, "Tscore.dat") || die "Cannot open input file.\n"; open (OUTPUT, ">L7AOUT.txt") || die "Cannot open file.\n"; print OUTPUT " CLASS TEST AVERAGES\n\n"; print OUTPUT " TEST\n"; print OUTPUT "NAME OF STUDENT AVERAGE\n\n"; read (INPUT, $studentname, 20); read (INPUT, $test1, 3); read (INPUT, $test2, 3); read (INPUT, $test3, 3); read (INPUT, $test4, 3); read (INPUT, $eor, 1); <INPUT>; $studentname3 = uc(substr ($studentname, 0, 3)); while ($studentname3 ne "END") { $avg = ($test1 + $test2 + $test3 + $test4) / 4; $studnum = $studnum + 1; $totavg = $totavg + $avg; printf OUTPUT ("%-24.20s %6.2f", $studentname, $avg); print OUTPUT "\n\n"; read (INPUT, $studentname, 20); read (INPUT, $test1, 3); read (INPUT, $test2, 3); read (INPUT, $test3, 3); read (INPUT, $test4, 3); read (INPUT, $eor, 1); <INPUT>; $studentname3 = uc(substr ($studentname, 0, 3)); } $totavg = $totavg / $studnum; print "\n\n"; printf OUTPUT ("%-24.22s %6.2f", $studnum, $totavg); print "Program completed Successfully."; close INPUT; close OUTPUT; exit 0;

In reply to Re: I'm having a strange bug with basic file input. I'm a total newb. by KingCupons
in thread I'm having a strange bug with basic file input. I'm a total newb. by KingCupons

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.