#!/usr/bin/perl use strict; my $undef_ref = undef; my $array_ref = [1,2,3]; if (!scalar @{$array_ref}) { print "foo\n"; } elsif (!scalar @{$undef_ref}) { print "bar\n"; }