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