in reply to String or array?

Why do you set $user->{host} to '*' if you are just deleting it and making it an array ref later? Perhaps I'm missing something, but why not do $user->{host} = [ '*' ];

Update:

depending on what the query returns, it's either a string or an array. I need to act on what's given.

In that case, you can use ref to figure out what you have:

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