title: Passing array, scalar and hash to subroutine in Perl
body: <p>What's the best way to send multiple arrays, variables, hashes to a subroutine?</p>
  
  <p>Simple form, works.</p>
  
  <pre><code>my $msg = &amp;getMsg(1,2,3);
  print $msg;
  
  sub getMsg {
      my($a, $b, $c) = @_;
  }
  </code></pre>
  
  <p>I am having difficulty with this version and am not sure how to send the data safely to the subroutine without using a global which is not what I want to do.</p>
  
  <pre><code>my @array = ('a','b','c');
  my $str = "Hello";
  my %hash = (
      'a' =&gt; ['100','nuts'],
      'b' =&gt; ['200','bolts'],
      'c' =&gt; ['300','screws'],
  );
  
  my $msg = getMsg(@array, $str, %hash);
  print $msg;
  
  sub getMsg {
      my (@a, $s, %h) = @_;
      my $MSG;
      foreach my $x (@a) {
          $MSG .= "\n$str, $x your hash value = $h{$x}[0] $h{$x}[1]";
      }
      return $MSG
  }
  </code></pre>