Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: Question about __PACKAGE__

by gam3 (Curate)
on Jan 22, 2010 at 12:24 UTC ( #818951=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Question about __PACKAGE__
in thread Question about __PACKAGE__

It is important to note that Perl OO does not have any "built in" concept of data. There is no default Constructor and the Destructor consists of a call to DESTROY.

It might be more descriptive to rewrite Foo->new()->hello('test5'); as

bless(\sub {}, 'Foo')->hello('test5');
This just blesses a CODE_REF for fun. It could be a HASHREF or some other REF. The only real difference between
'Foo'->hello()
and
bless(sub {}, 'Foo')->hello()
Besides the fact that the blessed version can contain data, is that just before the blessed object is Garbage Collected, DESTROY is called with it as the argument ($x->DESTROY). UNIVERSAL contains a DESTROY method, so it always exists.
-- gam3
A picture is worth a thousand words, but takes 200K.


Comment on Re^3: Question about __PACKAGE__
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://818951]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2015-07-01 19:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (17 votes), past polls