Dear monks I have modified as per zentara's advice but now it goes into a endless loop and get's killed ultimately. can some one help me in this.

use threads ; use feature "say"; #use strict; use warnings; `tr -d '\n' </home/guru/Desktop/sequence.fasta >modified_human_chr_1.t +xt`; my $input_file = "modified_human_chr_1.txt"; open my $hd, "<", $input_file or die "Couldn't open '$input_file' - $! +"; my $text=<$hd>; chomp($text); my $window=5; my $i=0; LOOP:seek $hd,$i,0; read ($hd,my $substring,$window); my %hash; if(length($substring)==$window) { $hash{$substring}=$i; $i++; goto LOOP; } my $count = keys %hash; my $j=0; foreach my $pattern (keys %hash) { if($j<=$count) { my $thr="thread".$j; $$thr=threads->create(\&hunter,$text,$pattern); $j++; } } my @returns; foreach $thread (threads->list) { if ($thread->is_joinable() ) { push @returns, $thread->join; } if( scalar (threads->list) == 0 ) {last;} } print "@returns\n"; sub hunter { my ($text,$pattern) = @_ ; my $offset = 0; print "\n$pattern ($window)\n"; print '~' x $window,"\n"; my $pos=index $text,$pattern,$offset; while ($pos != -1) { print $pos+1," to ",$pos+$window,"\n"; $offset = $pos + 99; $pos = index($text, $pattern, $offset); } }

In reply to Re^2: Trouble implementing threads by saranrsm
in thread Trouble implementing threads by saranrsm

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.