title: Why "Not an ARRAY reference" error?
body: <p>I have this script</p>
  
  <pre><code>#!/usr/bin/perl
  
  use strict;
  use warnings;
  
  use yy;
  
  my $data = [
      ["aax", "ert", "ddd"],
      ["asx", "eer", "kkk"],
      ["xkk", "fff", "lll"],
      ["xxj", "vtt", "lle"],
      ];
  
  use Test::More tests =&gt; 4;
  
  is(yy::type1_to_type2(\$data, 'aax'), 'ert');
  is(yy::type1_to_type3(\$data, 'asx'), 'kkk');
  is(yy::type2_to_type3(\$data, 'fff'), 'lll');
  is(yy::type3_to_type1(\$data, 'lle'), 'xxj');
  </code></pre>
  
  <p>which uses this module</p>
  
  <pre><code>package yy;
  
  sub typeX_to_typeY {
      my ($x, $y, $data, $str) = @_;
  
      foreach (@$data) {
      if ($_-&gt;[$x - 1] eq $str) {
          return $_-&gt;[$y - 1];
      }
      }
  
      return;
  }
  
  sub type1_to_type2 { typeX_to_typeY(1, 2, @_) }
  sub type1_to_type3 { typeX_to_typeY(1, 3, @_) }
  sub type2_to_type1 { typeX_to_typeY(2, 1, @_) }
  sub type2_to_type3 { typeX_to_typeY(2, 3, @_) }
  sub type3_to_type1 { typeX_to_typeY(3, 1, @_) }
  sub type3_to_type2 { typeX_to_typeY(3, 2, @_) }
  
  1;
  </code></pre>
  
  <p>and gives this error</p>
  
  <pre><code>Not an ARRAY reference at yy.pm line 6.
  # Looks like your test died before it could output anything.
  </code></pre>
  
  <p>The line it complains about is</p>
  
  <pre><code>foreach (@$data) {
  </code></pre>
  
  <p>Isn't this the way to pass an array reference?</p>
  
  <p>What am I doing wrong?</p>