in reply to Why do I get uninitialized value in substitution (s///) in my array?

s/xyz456/$genpass[0]/;

means

$_ =~ s/xyz456/$genpass[0]/;

You checked whether $genpass[0] was undef or not, but you didn't check $_.