title: Pass hash to subroutine inside a subroutine already passed that hash
body: <p>I am working with passing hashes to various subroutines, and I was wondering how to pass a hash to a subroutine and then pass the same hash inside that subroutine to a different subroutine and so on. </p>
  
  <p>For example, the following code works fine.</p>
  
  <pre><code>use strict;
  use warnings;
  
  my %hash = ( 
      key1 =&gt; 'value1',
      key2 =&gt; 'value2',
      key3 =&gt; 'value3',
      key4 =&gt; '', 
  );      
  
  print %hash, "\n"; 
  check_it(\%hash);
  
  sub check_it {
      my $params = shift; 
  
      foreach(keys %{$params}){        
          if($params-&gt;{$_}) {
              print "'$_' defined as '$params-&gt;{$_}'\n";
          }   
          else {
              print "'$_' not defined as '$params-&gt;{$_}'. Deleting it.\n"; 
              #delete $params-&gt;{$_};
              $params-&gt;{$_} = 'null';
          }     
      } 
  
      for ( my $i = 0 ; $i &lt; 7 ; $i++ ) {
          print "looping\n";
          &amp;check_tags_again(\%hash);
      }     
  }   
  
  sub check_tags_again {
      my $hash_now = shift;
  
      #check again...
      foreach(keys %{$hash_now}){
          print "An element of hash: ", $hash_now-&gt;{$_}, "\n";
          #if(defined $hash_now-&gt;{$_}){ delete $hash_now-&gt;{$_};}
      }
      &amp;check_tags_thrice(\%hash);
  }   
  
  sub check_tags_thrice {
      my $hash_now = shift;
  
      #check again...
      foreach(keys %{$hash_now}){
          print "An element of hash: ", $hash_now-&gt;{$_}, "\n";
          #if(defined $hash_now-&gt;{$_}){ delete $hash_now-&gt;{$_};}
      }   
  }   
  
  print "final hash:", %hash, "\n";
  </code></pre>
  
  <p>BUT, when I run the code that follows:</p>
  
  <pre><code>use strict;
  use warnings;
  use Data::Dumper;
  
  sub process_data {
  
      my $group_size = 10; 
  
      my %HoA = ( 
          flintstones =&gt; [ "fred",   "barney" ],
          jetsons     =&gt; [ "george", "jane", "elroy" ],
          simpsons    =&gt; [ "homer",  "marge", "bart" ],
      );      
  
      &amp;delete_stuff( \%HoA, $group_size );
      print "New group:\n";
      print Dumper( \%HoA );
      undef %HoA;
  }   
  
  sub delete_stuff {
      my $HoARef     = shift;
      my $group_size = shift;
  
      print "group size in sub $group_size\n";
  
      for ( my $j = 0 ; $j &lt; $group_size ; $j++ ) { 
          my $dlted = &amp;delete_other_stuff( \%HoA, $j );
          print "deleted? '$dlted'\n";
  
          if ( $dlted == 0 ) { 
              &amp;presence_check( \%HoA, $j );
          }   
  
          for ( my $i = 0 ; $i &lt; $group_size ; $i++ ) { 
          }   
      }   
  }   
  
  sub delete_other_stuff {
      my $HoAref  = shift;
      my $Dex     = shift;
      return $deleted;
  }   
  
  sub presence_check {
      my $HoAreF = shift;
      my $DeX    = shift;
  }
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code> Global symbol "%HoA" requires explicit package name at x.pl line 32.
   Global symbol "%HoA" requires explicit package name at x.pl line 35.
   Execution of x.pl aborted due to compilation errors.
  </code></pre>
  
  <p>I'm confused because I think it's doing the same thing as the first, but now it claims that <code>%HoA</code> was never initialized. </p>