use strict; use warnings; use feature 'say'; { package Local::Class; sub new { my ( $class ) = ( shift ); bless {}, $class; } sub AUTOLOAD { my ( $method ) = ( our $AUTOLOAD =~ /([^:]+)$/ ); if ( $method =~ /^(ARRAY|HASH|SCALAR|REF)/i ) { require Acme::Ref; my $real_coderef = $_[0]->can("HANDLE_$1") or die "Cannot handle $1 method"; splice @_, 1, 0, do { local $SIG{__WARN__} = sub {}; Acme::Ref::deref($method); }; goto $real_coderef; } return if $method eq 'DESTROY'; die "Could not load $method via AUTOLOAD"; } sub HANDLE_ARRAY { my ( $self, $array, @args ) = ( shift, shift, @_ ); say for @$array; } sub HANDLE_HASH { say "whatever"; } # etc... }; my $object = 'Local::Class'->new(); my $array = [ "Hello", "world" ]; $object->$array; $object->${\ [ "And", "again" ] };