Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: indirect object in camel book

by Anarion (Hermit)
on Oct 06, 2001 at 04:46 UTC ( [id://117149]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2025-07-08 09:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.