in reply to oop + named arguments

You could do my ($self, %args) = @_

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: oop + named arguments
by Limbic~Region (Chancellor) on Apr 05, 2006 at 20:07 UTC
    japhy,
    When I am doing this without using an existing wheel, it usually looks something like:
    sub thing { my $self = shift @_; croak "Incorrect number of arguments" if @_ % 2; my %arg = @_; for (@known_args) { # handle $arg{$_}; delete $arg{$_}; } if (keys %arg) { my $bad = join ' ', keys %arg; croak "The following args are invalid: $bad"; } # ... remainder of thing }

    Cheers - L~R