in reply to uninitialized value in substitution
You're implicitly binding the s/// to $_ which isn't initialized. s/$fields\[0\]/$user/; is really $_ =~ s/$fields\[0\]/$user/;.
ihb
Read argumentation in its context!