Something you should note with your hash:

Your @grades array has students with multiple grades. When you convert @grades to %grades, you are losing the first entry.

The following script

use Data::Dumper; @grades = qw(Noel 25 Ben 76 Clementine 49 Norm 66 Chris 92 Doug 42 Carol 25 Ben 12 Clementine 0 Norm 66); %grades = @grades; print Dumper \@grades; print Dumper \%grades;
will output
$VAR1 = [ 'Noel', '25', 'Ben', '76', 'Clementine', '49', 'Norm', '66', 'Chris', '92', 'Doug', '42', 'Carol', '25', 'Ben', '12', 'Clementine', '0', 'Norm', '66' ]; $VAR1 = { 'Chris' => '92', 'Carol' => '25', 'Doug' => '42', 'Norm' => '66', 'Clementine' => '0', 'Ben' => '12', 'Noel' => '25' };
and you'll see that only the last entry for each student is stored in your hash (which is fine if that is what you want to do, but I thought I would point that out just in case you didn't realize that was happening).

In reply to Re: Printing two variables in the same line by Anonymous Monk
in thread Printing two variables in the same line by JustLikeThat

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.