my @a = @$a_ref; # I know it's an array my %h = %$h_ref; # I know it's a hash my @h = values(%$h_ref); # I just want the values # Bascically what you're doing above. my @a = (ref($x) eq 'ARRAY') ? @$x : values(%$x);