in reply to Re^2: Threading and File Handles
in thread Threading and File Handles
My first thought is to forget about passing "filhandles" and to pass the "files saved in scalar variables" through the cond_broadcast facility in threads. I'm not too quick to whip off example code, but what I mean is to figure out how to pass scalars around between threads. Alot of examples have been posted how to do this. Then in each thread, use the "variable as a filehandle technique" like:
Now, in each thread, you can open and close on that variable, then "broadcast it" to the other threads where they can do the same thing.my $foo = ''; open FILEHANDLE, '+>', \$foo or die $!; print FILEHANDLE "Contents of File"; seek(FILEHANDLE,0,0); my @contents = <FILEHANDLE>; close FILEHANDLE or die $!; print 'From $foo: ', $foo, $/; print 'From file read: ', @contents, $/;
|
|---|