#!/usr/bin/perl -w use strict; use Carp; use Data::Dumper; sub array_ref { my $array_ref = shift; croak 'Not an array reference' unless ref($array_ref) eq 'ARRAY'; print Dumper($array_ref); } my @array = qw/ 1 2 3 4 5 /; my %hash = qw/ 1 1 2 2 3 3 4 4 5 5 /; array_ref(\@array); array_ref(\%hash); #### $VAR1 = [ '1', '2', '3', '4', '5' ]; Not an array reference at try.pl line 9 main::array_ref('HASH(0x81d4e14)') called at try.pl line 18