http://www.perlmonks.org?node_id=1148368


in reply to "Indirect" object syntax?

Hello muba,

Here’s the official explanation, from perlglossary:

  • indirect object

    In English grammar, a short noun phrase between a verb and its direct object indicating the beneficiary or recipient of the action. In Perl, print STDOUT "$foo\n"; can be understood as “verb indirect-object object”, where STDOUT is the recipient of the print action, and "$foo" is the object being printed. Similarly, when invoking a method, you might place the invocant in the dative slot between the method and its arguments:
    $gollum = new Pathetic::Creature "Sméagol"; give $gollum "Fisssssh!"; give $gollum "Precious!";
  • indirect object slot

    The syntactic position falling between a method call and its arguments when using the indirect object invocation syntax. (The slot is distinguished by the absence of a comma between it and the next argument.) STDERR is in the indirect object slot here:
    print STDERR "Awake! Awake! Fear, Fire, Foes! Awake!\n";

So in the case of $cgi = new CGI;, this is actually short for something like:

@args = (); $cgi = new CGI @args;

Does an expression such as $cgi = new CGI; violate the English rule that an indirect object is not present unless a direct object is also present? Yes, unless the (null) method arguments can be said to be “understood” in this case. (Cf. the sentence “Listen to me!” in which the subject “you” is also said to be “understood.”)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,