Given this
package Msg; sub connect { my ($pkg, $to_host, $to_port, $rcvd_notification_proc) = @_; } # ... Msg->connect($host, $port, \&rcvd_msg_from_server);
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.
"From the comment, an object was created. The reference is the anonymous hash with 2 members, and the class name is what? $pkg appears to be an undefined scalar?"
$pkg is "Msg".
"From the prior 'bless', a $conn has no methods"
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.
In reply to Re: Perl semi-object without a constructor
by tobyink
in thread Perl semi-object without a constructor
by Wiggins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |