my %mapping = ( ARRAY => '@', HASH => '%', SCALAR => '$', # GLOB => '?', # REF => '?', # CODE => '?', ); if (grep { $_ eq $type } keys %mapping) { if (isa($_[0], $type)) { return eval "$mapping{$type}{$_[0]}"; } else { return @_; } } else { return (); }