in reply to enabling OO and non-OO access to the same module using a hash reference
In what way does it not work for multi-layers?
should work just fine when coerced from @_ to %args. The only thing to watch out for is if the same sub can be used as an object method, then you'll want to check that first:Module::foo( blah => 'zap', baz => [ 4, 12, 15, 'Fibonacci' ], froop => { thwap => 'funny' }, );
(untested)my $self = undef; if (ref $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)) { $self = shift; } my %args = @_;
Now, granted, a hashref can be faster than this, but that wasn't your question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: enabling OO and non-OO access to the same module using a hash reference
by diotalevi (Canon) on Jan 15, 2007 at 17:32 UTC |