If you're trying to write a sub with default params, you can try this:

sub mysub
{
my ($a,$b,$c) = @_;

$a ||= 1;
$b ||= 2;
$c ||= 3;
}

Zarabozo, Francisco (GE, Corporate) wrote:
> Hello All,
>
> After reading a lot on the subject, I'm guessing that it's not possible to 
> do what I want to do, but anyway I wanted to ask you about and hopefuly be 
> wrong. :-)
>
> I want to write a sub so I can use it like this:
>
> --------------------------------
> mysub (a => 1, b => 2, c => 3) {
>    # ...CODE...
> };
> --------------------------------
>
> But, I haven't found any valid prototype combination to make that work. 
> After reading the perlsub documentation, at first I thought I would be able 
> to do so like this:
>
> --------------------------------
> sub mysyb (\%&) {
>    # ...CODE...
> }
> --------------------------------
>
> But, of course, I was wrong. Taking out the backslash is also wrong since 
> the % will eat anything after it.
>
>
> Please let me know if any of you know the way to correctly construct such 
> prototype.
>
> Thanks in advance.
>
>
> Cheers, :-)
>
> Paco
>
>
>
> _______________________________________________
> ActivePerl mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>   

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to