Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: questions about bless's second argument

by perlfan (Vicar)
on Nov 20, 2020 at 20:01 UTC ( [id://11123926]=note: print w/replies, xml ) Need Help??


in reply to questions about bless's second argument

Welcome! My preferred idiom or pattern looks like this,
package Widget; use strict; use warnings; # generic constructor, allows for any keys to be passed like, # my $widget = Widget->new(field1 => "value 1", field2 => "value 2", e +tc => "etc..."); sub new { my ($pkg, %self) = @_; # can validate parameters here... (I like Validate::Tiny) # technically it's a "package", also the 2nd argument to # bless is a string, literally just the "package" name ('Widget') return bless \%self, $pkg; } 1; #<-- note

I highly recommend looking at the following:

My standard advice is to stay away from any OO perl systems that promise the m00n until you understand how Perl makes all this happen. Conway's, Object Orient Perl is a must peruse.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-24 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found