in reply to Opening and closing files in loop
G'day lt007,
Welcome to the monastery.
Rather than continually changing the default filehandle with select, I'd use print with the required filehandle (e.g. print $fh qq{...}). Using this method, you only need to open the files once before the loop and close them once after the loop.
Your question title (Opening and closing files in loop) suggests you're maybe confused between select and open. You don't use open in your loop nor show any code where it is used.
You don't show how $max gets its value. This variable controls how many times the loop is entered. Try print "$max\n"; just before the loop to test this.
Did you intend to put an ampersand in front of randomPwd($nmbchars)? See perlsub for what it does and whether you need it (normally you don't).
-- Ken
|
|---|