#!/usr/bin/perl -w use strict; my %foo = ( a => 'b', b => 'c', ); print hash_or_hashref(%foo); print hash_or_hashref(\%foo); sub hash_or_hashref { die "missing options" unless $_[0]; # was it a hash or hashref passed. my $options; if (UNIVERSAL::isa($_[0], 'HASH')) { $options = shift; } else { $options = {@_}; } return $options->{a}; }