feathered_frog (feathered_frog) wrote in perl,
feathered_frog
feathered_frog
perl

Maybe a stupid HASH question but....

I've been self-learning perl from books and websites, and I am confused about the benefit of hashes....
An example often given is...

%HoH = (
flintstones => {
husband => "fred",
pal => "barney",
},
jetsons => {
husband => "george"
wife => "jane",
"his boy" => "elroy", # Key quotes needed.
},
simpsons => {
husband => "homer",
wife => "marge",
kid => "bart",
},
);
So, why is this better than just having a bunch of variables like: 

$flintstones_husband = "fred";
$flintstones_pal = "barney";
$simpsons_husband = "homer";
$simpsons_wife = "marge";
and so on...?
Subscribe
  • Post a new comment

    Error

    default userpic
  • 29 comments