my $thing = function_that_returns_arrayref_or_string; if( ref $thing eq 'ARRAY' ) { $user->{host} = $thing; } else { $user->{host} = [ $thing ]; }