use v5.12.0;
use warnings;
#use diagnostics;

use Data::Dump qw/pp dd ddx/;

tie my @arr, 'Tie::NewStdArray', [42..45];
#tie my %hsh, 'Tie::NewStdHash', {x=>"y"};



my $scl = "x";
my $obj = bless \$scl, "DUMMY";
ddx $obj;






#no warnings 'misc';
say $arr[$obj];



BEGIN {

    package Tie::NewStdArray;
    use Tie::Array;
    use Data::Dump;
    use Carp;
    our @ISA = ('Tie::StdArray');

    sub FETCH {
        my ( $self, $idx ) = @_ ;

        ddx '$idx', $idx;

        return $self->[$idx];
    }

    sub TIEARRAY {
        my ($class,$a_ref) = @_;
        ddx $a_ref;
        bless $a_ref, $class;
    }


    package Tie::NewStdHash;
    use Tie::Hash;
    use Data::Dump;

    our @ISA = ('Tie::StdHash');

    # sub FETCH {
    #     my ( $self, $idx ) = @_ ;
    #     return $self->{$idx};
    # }

    # sub TIEHASH {
    #     my ($class,$h_ref)    = shift;
    #     bless $h_ref, $class;
    # }

    package DUMMY;

}
