in reply to indirect object in camel book

What anybody noticed of my post is the last line:
"if i dont use a typeglob on the prototype it works"
This calls the method of CGI
#!/usr/bin/perl -w use strict; use CGI; my $query=new CGI; sub new($) { print "Ouch!!\n"} my $query2=new CGI;

Then, I dont understand how is called a function or another depending of the definition of the prototype.

$anarion=\$anarion;

s==q^QBY_^=,$_^=$[x7,print


Replies are listed 'Best First'.
Re: Re: indirect object in camel book
by BrentDax (Hermit) on Oct 06, 2001 at 07:41 UTC
    It's because * in a prototype is used for a filehandle. Quick, what does this do:
    open MYCLASS, "$filename"; print MYCLASS; #print to MYCLASS or call MYCLASS->print?
    How about this?
    sub new(*) {...} open MYCLASS, $filename; new MYCLASS; #main::new(*MYCLASS) or MYCLASS->new?
    And this?
    sub new(*) {...} open CGI, $filename; new CGI; #main::new(*CGI) or CGI->new?
    In all those (except the first) it calls main::new, passing it the filehandle. And since filehandles autovivify, you don't even need to have it open()ed.

    =cut
    --Brent Dax
    There is no sig.