Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Opening and closing files in loop

by kcott (Abbot)
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


Comment on Re: Opening and closing files in loop
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-07-26 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls