Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Given this
The connect method is not being called with three arguments, it's being called with four arguments. The first argument is the string "Msg" - that is, the part before the ->. This is how method calls work in Perl (we borrowed it from Python); the thing before the arrow gets passed in as the first argument.
$pkg is "Msg".
Why do you think $conn has no methods? Something to do with the hash only having a couple of uninteresting key-value pairs? An object's methods have nothing to do with the blessed reference itself, but are taken from the package it is blessed into. So because $conn is blessed into the Msg package, all the subs defined within Msg are available as methods for $conn.
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
In reply to Re: Perl semi-object without a constructor
by tobyink
|
|