in reply to An alternate way of implementing import with options
in thread Passing parameters to a module's import function
Or, I might even do a moving-splice() trick:my %args; push @{ $args{ref($_) eq 'HASH' ? 'opt' : 'ext'} }, $_ for @_;
</code>sub import { my $self = shift; my ($i,$j,@options); for (@_) { if (++$j, ref($_) eq 'HASH') { push @options, splice(@_, $j + --$i, 1); $_ = $_[$j+$i], redo if $j + $i < @_; } } # handle @options # @_ now only holds elements which aren't hash refs $self->SUPER::import(@_); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 2: An alternate way of implementing import with options
by tilly (Archbishop) on Feb 13, 2001 at 21:43 UTC | |
by japhy (Canon) on Feb 13, 2001 at 21:46 UTC |