Hi, I am using the following code segment to find out the lines which match the given critiria. @array contains the lines from the text file(10000 rows & 90 cols). It takes 10secs to findout the matched records. Is there any ways to increase the performance?.
file:foreach (@array){ $match=0; my @tmparr; my @line=split(/\t/); foreach $key_pos(sort keys(%conwithposition)) { if ($conwithposition{$key_pos}[0] eq '=') { if ($conwithposition{$key_pos}[1] eq $line[$key_pos] +) { $match=1; }else{ $match=0; next file; } }elsif($conwithposition{$key_pos}[0] eq '!='){ if ($conwithposition{$key_pos}[1] ne $line[$key_pos] +) { $match=1; }else{ $match=0; next file; } }elsif ($conwithposition{$key_pos}[0] eq '>'){ if ($conwithposition{$key_pos}[1] gt $line[$key_pos] +) { $match=1; }else{ $match=0; next file; } }elsif ($conwithposition{$key_pos}[0] eq '>='){ if ($conwithposition{$key_pos}[1] ge $line[$key_pos] +) { $match=1; }else{ $match=0; next file; } }elsif ($conwithposition{$key_pos}[0] eq '<'){ if ($conwithposition{$key_pos}[1] lt $line[$key_pos] +) { $match=1; }else{ $match=0; next file; } }elsif ($conwithposition{$key_pos}[0] eq '<='){ if ($conwithposition{$key_pos}[1] le $line[$key_pos] +) { $match=1; }else{ $match=0; next file; } } } if ($match){ #All the conditions met. Push this line of file to +@result_arr foreach $col(sort {$a<=>$b} keys(%cols_pos)){ push @tmparr,$line[$col]; } $tmparr=join("|",@tmparr); push @listcols,$cols_pos{$col}; push @result_arr,[ $tmparr ]; } }#file:for
Thanks in Adv,

In reply to Increasing the efficiency of the code by Anonymous Monk

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.