Here is by code :
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my $var = {
Cars => {
cars_name => [
"GT500",
"Beetle",
"P1800"
]
},
Bikes => {
Bikes_name => [
"Pulsar",
"Discover",
"CBR"
]
}
};
#Traversing the hash of hash of array
print "$var\n";
foreach my $k1 (keys %{$var}) {
print "$k1\n";
print $var->$k1;
#foreach my $k2 (keys %{$var->$k1}) {
#print"$k2\n";
#}
}
Whenever i am trying to print cars_name and Bikes_name , i am getting an error message saying the Can’t call method Cars on Unblessed reference. I am not able to figure it out where am i doing mistake. Well, by mine understanding this print $var->$k1; line creating a prob. So please can any body help me out of this.
Thanks
that is calling a method on an object. You want to access a hash: