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?

Module::foo( blah => 'zap', baz => [ 4, 12, 15, 'Fibonacci' ], froop => { thwap => 'funny' }, );
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:
my $self = undef; if (ref $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)) { $self = shift; } my %args = @_;
(untested)

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

    You've just broken polymorphism with your use of ref() and UNIVERSAL::isa(). The correct incantation follows.

    defined( blessed( $_[0] ) ) and $_[0]->isa( __PACKAGE__ )

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊