Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: What Are The Rules For Subs And Modules When Fed Wrong Input

by Cody Pendant (Prior)
on Jul 21, 2002 at 04:02 UTC ( #183758=note: print w/replies, xml ) Need Help??


in reply to Re: What Are The Rules For Subs And Modules When Fed Wrong Input
in thread What Are The Rules For Subs And Modules When Fed Wrong Input

sub foo ($$) { print "@_\n"; } foo(1,2,3); >>> Too many arguments for main::foo at ...
Could you please explain that in a little more detail? I'd really appreciate it, as I don't know what's meant by "prototypes".

But my concern is about what to do if I'm writing a module, not if I'm using a module. Perhaps the real answer is, write good and unambiguous documentation?
--

($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;

Replies are listed 'Best First'.
Re: Re: Re: What Are The Rules For Subs And Modules When Fed Wrong Input
by dpuu (Chaplain) on Jul 21, 2002 at 04:09 UTC
    When you define a sub, you can tell the compiler what args it expects. In my example, the ($$) means that it must be passed two scalar values. Rather than me going into more detail myself, checkout this tutorial. Another view is given by Tom Christiansen, here. Also, don't forget the Camel book. --Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2020-04-03 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (32 votes). Check out past polls.

    Notices?