sub normalize_date { my $date_proto = shift; my $stringified = "$date_proto"; # Check to see if it's NOT a reference unless ($stringified =~ /\(0[Xx]\d+\)$/) { return split /\D+/, $date_proto; } # At this point, we know we have a reference of some sort ... # Let's see if it acts as an array ... if ( eval { @{$date_proto}; 1} } ) { # We know we can treat $date_proto as an array return $date_proto; } # At this point, we don't know what to do with $date_proto. # (Well, the OP hasn't spec'ed it out ...) } #### package Date::As::Hash; use overload '""' => 'stringify'; # Some stuff here ... sub stringify { my $self = shift; "$self->{MONTH}/$self->{DAY}/$self->{YEAR}"; }