in reply to Read value from file, replace, then write to new file

{ my @possible = ( 'a' .. 'k', 'm', 'n', 'p' .. 'z', 2 .. 9, 'A' .. +'H', 'J' .. 'N', 'P' .. 'Z' ); sub generatePassword { my $length = shift; return join '', map $possible[ rand @possible ], 1 .. $length; } } { my $readfile = 'index.txt'; my $writefile = 'index.html'; sub pleaseGodWork { my $password = generatePassword 8; open my $IN, '<', $readfile or die "Cannot open $readfile: $!" +; open my $OUT, '>', $writefile or die "Cannot open $writefile: +$!"; select $OUT; s/\Q***password***/$password/g, print while <$IN>; } } pleaseGodWork; exit 0;