hello

i have used the code and comment, because my problem was a little similar. i need to access to a big file (6Go / 12M protein records) to search for fuzzy similary

so i give my solution, it's a good start and maybe it will be useful to someone

regards

yovoa

#! perl -slw use strict; use warnings; use threads; use Thread::Queue; my $file="/path_to_the_file" ; our $file_handler ; our $ref_file_handler ; my ( $process_1 , $process_2 , $process_3 ) ; my $flag_on_file = Thread::Queue->new ; # main open $file_handler, '<', $file or warn "$file : $!" and die; $flag_on_file->enqueue(fileno($file_handler)); # threads creation $process_1 = threads->new( \&my_sub ); $process_2 = threads->new( \&my_sub ); $process_3 = threads->new( \&my_sub ); # waiting for all threads to stop before exit $process_1->join; $process_2->join; $process_3->join; # end main # sub sub my_sub { my( $fileno ) = $flag_on_file->dequeue ; open $ref_file_handler, "<&=$fileno" or warn $! and die; for ( 1..10 ) { # do something with the file # exemple print threads->self->tid.": ".scalar <$ref_file_handler> ; } close $ref_file_handler; $flag_on_file->enqueue(fileno($file_handler)); # do something with data } exit;

In reply to Re: FileHandles and threads by Anonymous Monk
in thread FileHandles and threads by sodul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.