Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Indirect Object Syntax

by bliako (Monsignor)
on Nov 09, 2021 at 09:26 UTC ( #11138600=note: print w/replies, xml ) Need Help??


in reply to Re^2: Indirect Object Syntax
in thread Indirect Object Syntax

Is new not a keyword that Perl understands without any context other than a module name will follow?

Technically, one can use any valid sub name instead of new for the role of "create object" (i.e. blessing a hash with the module name), when writing an OOP module -- and can use sub new for some other function, confusing yes but it shows that name new is nothing special:

{ package MyObj; sub retro { bless { name => $_[1] }, $_[0] } sub string { join ', ', values %{ $_[0] } } } my $obj = MyObj->retro("aghag"); my $obj2 = retro MyObj("aaa"); # with the usual caveats

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2022-05-22 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (78 votes). Check out past polls.

    Notices?