in reply to uber-reference

I was going to propose basically what merlyn wrote above (except also preserving void context rather than transposing it into regular scalar context).

Thinking further on it, I'd like Perl to provide more context information at some point so it'd be nice to have a solution that would forward whatever context information is available without having to add cases as Perl changes.

Here is a solution that does that:

sub __PACKAGE__::NewWay::new { my $class= shift; API->use_the_new_way; return bless [], $class; } sub __PACKAGE__::NewWay::DESTROY { API->use_the_old_way; } sub AUTOLOAD { ... my $newway= __PACKAGE__::NewWay->new(); goto \&$func; # or, if you want to keep AUTOLOAD in the stack trace: # return &$func( @_ ); }
I haven't tested that so let me know if you have problems with it. ):

        - tye (but my friends call me "Tye")