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

It looks like you want something like this:

#!/usr/bin/perl use warnings; use strict; use Tie::File; my $users = '/home/v0x9849/scripts/new.users'; tie my @nup, 'Tie::File', $users or die "Cannot open $users: $!"; for ( @nup ) { if ( $_ eq 'xyz456' ) { $_ = generatePassword( 10 ); } } untie @nup; sub generatePassword { my $length = shift; my @possible = ( 'a' .. 'k', 'm', 'n', 'p' .. 'z', 2 .. 9, 'A' .. +'H', 'J' .. 'N', 'P' .. 'Z' ); return join '', map $possible[ rand @possible ], 1 .. $length; }
  • Comment on Re: Why do I get uninitialized value in substitution (s///) in my array?
  • Download Code