Re: general subroutine question
- From: info@xxxxxxxxxxxx (D. Bolliger)
- Date: Wed, 30 Aug 2006 21:11:06 +0200
Derek B. Smith am Mittwoch, 30. August 2006 20:44:
store where?
or pass?
pass to what?
Did you mean: Is there a way for a subroutine to
react to a call with to many
arguments?
sub accept_max_5_arguments {
die 'too many arguments!' if @_ > 5;
}
sub accept_max_x_arguments { # apart from the first
my $maxargs=shift;
die 'too many arguments!' if @_ > $maxargs;
}
If this does not help: Could you, long time posting
list member, clarify your
question?
Dani
#####################################################
Why is it so many people on the list are sarcastic???
example from Dani: "Could you, long time posting
list member, clarify your
question?"
Sarcasm was not intended - I'm simply not a native english speaker and I don't
mention it in every post :-)
What I wanted to say - without offending you - was: You asked a lot of
questions, therefore have a lot of experience with this list, and should know
that and how the questions influnce the answers. As more precise the
question, as more precise the answer can be (mostly not from me ;-) ).
["precise" is hardly the correct english word, but...]
This does not help the situation.
Anyway, I will claify. Is there an inheriant Perl
rule, one that does not require you to code one up,
that disallows a subroutine to pass too may arguments
to another subrountine
I don't know of such a thing. How should such a feature "don't allow too many
arguments without coding something that specifies 'many'" be implemented?
Christian mentioned prototypes, maybe that's what you're looking for, but they
should be avoided, they do more than just defined the maximum of possible
arguments, and involve some sort of "coding".
or scalar?
I never heard of a way to pass arguments to (normal) scalars in perl. Somebody
else may know more.
Likewise, is there a inheriant Perl rule, one that
does not require you to code one up, that disallows a
subroutine to store too many arguments in @_?
If not then yes your example will suffice.
I don't think there is such a rule, but wait for other answers.
Dani
.
- Follow-Ups:
- Re: general subroutine question
- From: Derek B. Smith
- Re: general subroutine question
- References:
- Re: general subroutine question
- From: Derek B. Smith
- Re: general subroutine question
- Prev by Date: Re: general subroutine question
- Next by Date: Re: general subroutine question
- Previous by thread: Re: general subroutine question
- Next by thread: Re: general subroutine question
- Index(es):
Relevant Pages
|