On 5/8/07, yitzle <[EMAIL PROTECTED]> wrote:
What would be the 'correct' way to deal with a function that takes eg 2 scalars and an array?
snip
There are many methods. I would do this: foo($first, $last, [EMAIL PROTECTED]); sub foo { croak "foo expects three arguments, two scalars and an arrayref. You gave (@_)" unless @_ == 3 and ref($_[0]) == ref($_[1]) == '' and ref($_[2]) eq 'ARRAY'; my ($first, $last, $array) = @_; ... } or, if $first and $last have a specific pattern they must match: sub foo { croak "foo expects three arguments, two scalars and an arrayref. You gave (@_)" unless @_ == 3 and $_[0] =~ /pattern/ and $_[1] =~ /pattern/ and ref($_[2]) eq 'ARRAY'; my ($first, $last, $array) = @_; ... } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/