Blessing a data structure _into_ a class associates that data structure with the ->methods (subroutines) of the class. If permits you to call those methods on that data. That is to say, bless turns a reference to a data structure into an object.
An object gives (or at least should give) you a black box routine, with a predictable and stable interface. You should be able to invoke $object->methods on the object (and the blessed reference to a data structure) without having to know the details of what happens inside the black box (class or package). By adding to that an understanding of inheritance, it is possible to use Modules (packages, classes), and to inherit methods from those modules. This is because the constructors (the ->new() methods) of those modules return a "blessed" reference that associates that module's methods (subroutines) with the referenced data structure, giving you direct access to all that code in the use'd module.
Someone around here has a sig file pointing out that 90% of every perl script has already been written. That 90% are the modules (cpan or home grown) upon which you build a specific application.
-- Hugh
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.