title: Perl : Trying to deference an array after sorting it
body: <p>I am currently writing a perl script where I have a reference to an array (students) of references. After adding the  hash references to the array. Now I add the references to the array of students and then ask the user how to sort them. This is where it gets confusing. I do not know how to deference the sorted array. Using dumper I can get the sorted array but in a unorganized output. <strong>How can I deference the array of hash references after sorting?</strong></p>
  <pre><code>#!bin/usr/perl
  use strict;
  use warnings;
  use Data::Dumper;
  use 5.010;
  #reference to a var $r = \$var; Deferencing $$r
  #reference to an array $r = \@var ; Deferencing @$r
  #referenc to  a hash $r = \%var ; deferencing %$r
  
  my $filename = $ARGV[0];
  my $students = [];
  
  
  
  
  open ( INPUT_FILE , '&lt;', &quot;$filename&quot; ) or die &quot;Could not open to read \n &quot;;
  
  
  sub readLines{
      
      while(my $currentLine = &lt;INPUT_FILE&gt;){
          chomp($currentLine);
          my @myLine = split(/\s+/,$currentLine);
          my %temphash = (
          name =&gt; &quot;$myLine[0]&quot;,
          age  =&gt; &quot;$myLine[1]&quot;,
          GPA  =&gt; &quot;$myLine[2]&quot;,
          MA   =&gt; &quot;$myLine[3]&quot;
          );
          pushToStudents(\%temphash);
      }
      
  }
  
  sub pushToStudents{
      my $data = shift;
      push $students ,$data;
  }
  
  sub printData{
      
      my $COMMAND = shift;
      
      if($COMMAND eq &quot;sort up&quot;){
          my @sortup = sort{ $a-&gt;{name} cmp $b-&gt;{name} } @$students;
          print Dumper @sortup;
          
      }elsif($COMMAND eq &quot;sort down&quot;){
          my @sortdown = sort{ $b-&gt;{name} cmp $a-&gt;{name} } @$students;
          print Dumper @sortdown;
          //find a way to deference so to make a more organize user friendly read.
          
      }else{
          print &quot;\n quit&quot;;
      }
      
      
  }
  
  readLines();
  #Output in random, the ordering of each users data is random
  printf&quot;please choose display order : &quot;;
  my $response = &lt;STDIN&gt;;
  chomp $response;
  printData($response);
  </code></pre>