in reply to Why do I get uninitialized value in substitution (s///) in my array?
s/xyz456/$genpass[0]/; [download]
means
$_ =~ s/xyz456/$genpass[0]/; [download]
You checked whether $genpass[0] was undef or not, but you didn't check $_.