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