Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Opening and closing files in loop

by kcott (Chancellor)
on Oct 22, 2012 at 08:49 UTC ( #1000292=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000292]
[planetscape]: boo
marto faints

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-04-27 09:42 GMT
Find Nodes?
    Voting Booth?