174

References & Structures
References as Return Values

  • References may be returned from subroutines
      sub Test {
      	$myHashReference = { 'a' => "ape", 'b' => "bat" };
      	return( $myHashReference );
      }
      

  • The return values may then be dereferenced
      $myHashRef = &Test();
      
      foreach $key ( keys %$myHashRef ) {
      	print "$key = $$myHashRef{$key}\n";
      }