#!/usr/bin/env perl use strict; use warnings; use 5.010; use Scalar::Util qw(reftype); package Package_a_ref; sub new { return bless [ qw( a b c ) ], shift; } package ARRAY; sub new { return bless { one => 1 }, shift; } package main; sub print_array_ref_AAA { # ref my ( $a_ref ) = @_; die ">no arguments" if not @_; die ">not defined" if not defined $a_ref; die ">not a reference" if not length ref $a_ref; die ">not an ARRAY reference" if ref( $a_ref ) ne 'ARRAY'; say for @$a_ref; } sub print_array_ref_BBB { # reftype my ( $a_ref ) = @_; die ">no arguments" if not @_; die ">not defined" if not defined $a_ref; die ">not a reference" if not defined reftype( $a_ref ); die ">not an ARRAY reference" if reftype( $a_ref ) ne 'ARRAY'; say for @$a_ref; }