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

Although you show us how you generate the password list, which doesn't seem relevant at all, you don't provide us with sample failing user list data. Your substitution acts on $_ (the default variable) which takes the value of each entry in @nup in turn. If you see an undefined variable warning then most likely there is an undef in @nup nad that implies something bad about your users data.

Try providing a sample user data file with failing data in a __DATA__ section following your sample program. Something like:

use warnings; use strict; my @genpass = (1 .. 3); my @nup = (<DATA>); foreach (@nup) { s/xyz456/$genpass[0]/; shift (@genpass); } __DATA__ 1 2 3

True laziness is hard work
  • Comment on Re: Why do I get uninitialized value in substitution (s///) in my array?
  • Download Code

Replies are listed 'Best First'.
Re^2: Why do I get uninitialized value in substitution (s///) in my array?
by graff (Chancellor) on Aug 10, 2009 at 03:36 UTC
    Though it's certainly well intentioned and not unreasonable to draw attention to the content of the "user list" data file, I can't imagine how the OP code could be getting an "undef" element in the @nup array.

    Have you ever encountered a situation where @array = <FILE> produces an undef element in the array? What sort of condition in a data file would cause that?

    I think ig's question below is more likely to be on the mark.