Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Writing to a file

by Cine (Friar)
on Aug 20, 2001 at 23:30 UTC ( [id://106329]=note: print w/replies, xml ) Need Help??


in reply to Writing to a file

output to $tmp_file$$ instead and then join the tempfiles afterwars if necessary.
$$ is current pid, if you were unsure.

Update:
Ups... $$ in this case is the same always :(
use
system("perl -e 'myscript.prl $id >> $tmp_file\$\$' &");
instead

T I M T O W T D I

Replies are listed 'Best First'.
Re: Re: Writing to a file
by maverick (Curate) on Aug 20, 2001 at 23:35 UTC
    This wouldn't work because $$ would be the same for every instance of the system call. Since the code is using a for loop, try using the counter variable to uniquely name the files:
    system("myscript.prl $id > $tmp_file$i");

    /\/\averick
    perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"

Re: Re: Writing to a file
by jalebie (Acolyte) on Aug 20, 2001 at 23:33 UTC
    The problem with that is that I am planning to run the for loop for over a 100,000 times easily, which would generate a 100,000 of temp files
      Cant you change your called script to use Sys::Syslog, that should solve your problem...

      T I M T O W T D I
      You are going to get a problem with open filehandles and other resources if you are planning on starting 100k processes at once...
      Perhaps you should just open 10-100 at a time and wait for them to finish and then continue...

      T I M T O W T D I

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found