title: cant retrieve values from hash reversal (Perl)
body: <p>I've initialized a hash with Names and their class ranking as follows</p>
  
  <pre><code>a=&gt;5,b=&gt;2,c=&gt;1,d=&gt;3,e=&gt;5
  </code></pre>
  
  <p>I've this code so far</p>
  
  <pre><code>my %Ranks = reverse %Class;     #As I need to find out who's ranked first
  print "\nFirst place goes to.... ", $Ranks{1};
  </code></pre>
  
  <p>The code only prints out</p>
  
  <pre><code>"First place goes to...."
  </code></pre>
  
  <p>I want it to print out </p>
  
  <pre><code>First place goes to....c
  </code></pre>
  
  <p>Could you tell me where' I'm going wrong here?</p>
  
  <p>The class hash prints correctly 
   but If I try to print the reversed hash using </p>
  
  <pre><code>foreach $t (keys %Ranks) { 
  print "\n $t $Ranks{$t}"; }
  </code></pre>
  
  <p>It prints </p>
  
  <pre><code>5
  abc23
  cab2
  ord
  </code></pre>
  
  <p>If this helps in any way</p>
  
  <p>FULL CODE</p>
  
  <pre><code>#Script to read from the data file and initialize it into a hash
   my %Code;
   my %Ranks;
  
   #Check whether the file exists
   open(fh, "Task1.txt") or die "The File Does Not Exist!\n", $!;
  
  while (my $line = &lt;fh&gt;) {   
  chomp $line;
      my @fields = split /,/, $line;
      $Code{$fields[0]} = $fields[1];
      $Class{$fields[0]} = $fields[2];
  } 
  close(fh); 
  
  #Prints the dataset 
  print "Code \t Name\n";
  foreach $code ( keys %Code) {
      print "$code \t $Code{$code}\n";
  }
  
  
  #Find out who comes first
  my %Ranks = reverse %Class;
  
  foreach $t (keys %Ranks)
  {
      print "\n $t $Ranks{$t}";
  }
  print "\nFirst place goes to.... ", $Ranks{1}, "\n";
  </code></pre>