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


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.