use Tie::Constrained; tie my $array_ref, 'Tie::Constrained', sub { ref $_[0] eq 'ARRAY' };