title: I defined a hash, but exists function throws an error saying it's not a hash
body: <p>This problem seems to be one of scope.  The line with the exists function on it throws an error saying that it's not receiving a hash as an argument.  How can I make so the value being passed to the exists function is my hash?</p>
  
  <pre><code>#!/usr/bin/perl
  
  use warnings;
  use strict;
  
  open FH, 'test_out' or die $!;
  
  my %pn_codes = ();
  
  while(&lt;FH&gt;) {
      if(/.*PN=(\d*)/) {
          my $pn = $1;
          if(exists %pn_codes{$pn}) {
              print($pn, "exists");
          } else {
              %pn_codes{$pn} = 1;
          }
      }
  }
  </code></pre>