title: "Can't use string ("") as a HASH ref while "strict refs" in use at" error while assigning hash to an hash in perl
body: <p>I'm assigning an hash <code>%attributes</code> to another hash <code>%attributes_r</code>. I need to print it as key/value pair of that hash <code>%attributes</code>, as mentioned below. But, while printing, why do I get this error, &quot;Can't use string (&quot;&quot;) as a HASH ref while &quot;strict refs&quot; in use at&quot;  in this line &quot;foreach my $key1 (keys %{$attributes_r{$key}})    {&quot; ?</p>
  <p><strong>My Code:</strong></p>
  <pre><code>use strict;
  use warnings;
  our %attributes_r;
  my %attributes = ('clear'      =&gt; 0,
                 'reset'      =&gt; 0,
                 'bold'       =&gt; 1,
                 'dark'       =&gt; 2,
                 'underscore' =&gt; 4,
                 'blink'      =&gt; 5,
                 'reverse'    =&gt; 7,
                 'concealed'  =&gt; 8
                 );
  
  
  for (keys %attributes) {
      $attributes_r{$attributes{$_}} = $attributes{$_};
      # print &quot;$_ =&gt; $attributes_r{$attributes{$_}}\n&quot;;
  }
  
  
  foreach my $key (keys %attributes_r)    {
      foreach my $key1 (keys %{$attributes_r{$key}})    {
          print &quot;$key1 = &gt; $attributes_r{$key}{$key1}\n&quot;;
      }
  }
  </code></pre>
  <p>Any help is appreciated.</p>