Just another Perl shrine | |
PerlMonks |
Re: When hashes aren't enoughby BigLug (Chaplain) |
on May 26, 2004 at 12:10 UTC ( [id://356550]=note: print w/replies, xml ) | Need Help?? |
Many wiser monks have had their say, so let me add my own $0.02. If you're just storing data, use a Hash of Hashes (countles examples above). If your data should be intelligent, use Objects. Consider and example similar to that in perltoot: You run a business, you employ people (class 'Employee'). They all do different things, they all get paid different amounts and all work different hours. So, in procedural programming we'd have to know all this and branch around the place like crazy. With OO, it's all under the bonnet and we dont need to touch anything:
As you can see, the objects are intelligent, so it doesn't matter that we tell all the objects ($roger, $sally and $mark) exactly the same thing, they all know, under the hood, what to do. To learn how to do that, read perltoot. It's not only a good tutorial, it's an easy read and you'll come away having learned something about perl that you didn't know before. Plus, learning OO is very PerlMonk.
"Get real! This is a discussion group, not a helpdesk. You post something, we discuss its implications. If the discussion happens to answer a question you've asked, that's incidental." -- nobull@mail.com in clpm
In Section
Seekers of Perl Wisdom
|
|