Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

while searching for perl codes in the internet I found something pretty strange(to me), I don't remember what site it was(in the time I didn't got a chance to copy the url sorry) but the code was like this:
sub foo ($$) { #somecode }
what are those $$ in the sub name for ? I didn't found any doc about it (don't know what to search for) can someone point me to some ?

Replies are listed 'Best First'.
Re: strange subs
by si_lence (Deacon) on Jun 10, 2009 at 12:10 UTC
    It is called a prototype. It lets you put constraints on the number and types of arguments.

    cheers si_lence

Re: strange subs
by dHarry (Abbot) on Jun 10, 2009 at 12:08 UTC
Re: strange subs
by shmem (Chancellor) on Jun 10, 2009 at 13:17 UTC
Re: strange subs
by Unforgiven (Hermit) on Jun 10, 2009 at 14:25 UTC
    Others already mentioned reading perlsub, which looks to cover the topic well, but I thought I'd mention that there's also a good sized section on this in "Programming Perl" as well. From the looks of it though, you'd be fine just reading one or the other.
Re: strange subs
by Anonymous Monk on Jun 10, 2009 at 12:26 UTC
    thanks to both of you. I founded.
      sub foo($$) # it strictly allows two scalar values as a arguments from the function call or else it throw error..In normal case it dont it accepts as many number of arguments Thanks everyone for suggesting perlsub and other usefull links
Re: strange subs
by Anonymous Monk on Jun 11, 2009 at 11:22 UTC
    This is funciton protyping, indicating that this funciton can take will expect two scalars as an argument
Re: strange subs
by paradox242 (Initiate) on Jun 11, 2009 at 23:20 UTC
    That's a subroutine prototype. The '$$' indicates that it accepts exactly two arguments, both of which will be evaluated in a scalar context. See perldoc perlsub.
Re: strange subs
by Anonymous Monk on Jun 11, 2009 at 23:24 UTC
    You're referring to what we call prototy-- oh, nevermind.
Re: strange subs
by Anonymous Monk on Jun 15, 2009 at 09:11 UTC
    sub foo($$) it mean you need to give two scalar for subroutine. ex: foo( $name, $val);