in reply to uninitialized value in substitution

Your s/// is defaulting to use $_, which is not initialized. If I understand what you're trying to do, use $vhost =~ s/$fields[0]/$user/. Note that you shouldn't escape the brackets for the array index.

HTH