Your @grades array has students with multiple grades. When you convert @grades to %grades, you are losing the first entry.
The following script
will outputuse 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;
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).$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' };
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |