Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Creating 'new' subroutine.

by tobyink (Canon)
on Oct 11, 2013 at 12:04 UTC ( [id://1057875]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Creating 'new' subroutine.
in thread Creating 'new' subroutine.

If we're guessing at intentions, then I might wager:

$options = scalar(@_) == 1 ? $_[0] : { @_ };

Though that's probably better written as:

$options = { scalar(@_) == 1 ? %{$_[0]} : @_ };

... to deliberately shallow clone in the case of a hashref.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 12:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found