I've been trying to learn object oriented perl since a few days and i've been doing considerably well except for one thing (or so i think!).
I'm not able to get what exactly is the difference between Tie and Bless in perl.
As far as the function prototype goes i know bless takes in reference to a variable (i stress on it being a varaible, i.e. hash or list or scalar, correct me if i'm wrong) and optionally the name of the package and blesses it (whatever that means) into the package.
Tie on the other hand takes in two arguments, a variable and the name of the class that it ties the variable into and optionally any arguments that needs to passed to the constructor of that class.
I want to know in terms of the symbol table manipulation or package namespace etc what this blessing or tieing operation is actually doing?
Is it just making the reference to the object belong to the class by putting it into its namespace? is it just appending the name of the class and '::' to the variable?
what is going on beneath the hood in these two cases?
i appreciate all your help.
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.