I have written a script, but the input is huge so my script taking days to finish

Its a kind of network log report

The input lines exceeds 700000

Input: c 1 2 q 2 5 c 3 9 q 6 7 c 2 6 q 4 5 c 1 5 c 8 7 c 2 6 c 6 3 c 4 8 c 8 1 c 3 9 c 1 2 q 4 3 c 8 4

here 'c' means connection, 'q' means query. We need to cumulate all the connections and while reading query we need to answer the query, whether the systems are connected or not. Finally we need to display how many query answered and failed. The answer for the input is 1,3, (q 4 3 connected and remaining queries are failed)

my code is here

my $queryCount=0; my $answeredCount=0; my $connectionText; open(INP, $ARGV[0]); while(<INP>) { chomp($_); $inputtext=$_; if ($inputtext=~m/q (\d+) (\d+)/) { $answeredCount++ if ($connectionText=~m/(?:\b$1\b[^\|]*\b$2\b| +\b$2\b[^\|]*\b$1\b)/); $queryCount++; } elsif ($inputtext=~m/c (\d+) (\d+)/) { my $fnum=$1; my $snum=$2; if ($connectionText=~m/\b$fnum\b[^\|]*\b$snum\b/) {} elsif ($connectionText=~m/\b$fnum\b/ and $connectionText=~m/\b +$snum\b/) { $connectionText=~s/\b$fnum\b(.*?)\|([^\|]*\b$snum\b.*?)(\| +|$)/$fnum.','.$2.','.$1.$3/e; $connectionText=~s/\b$snum\b(.*?)\|([^\|]*\b$fnum\b.*?)(\| +|$)/$snum.','.$2.','.$1.$3/e; } elsif ($connectionText=~m/\b(?:$fnum|$snum)\b/) { $connectionText=~s/\b(?:$fnum|$snum)\b(.*?)\|/$fnum.','.$s +num.','.$1.'|'/e; } else { $connectionText.=$fnum.",".$snum."|"; } $connectionText=~s/,,/,/g; $connectionText=~s/,\|/\|/g; } } close (INP); print "$answeredCount,".($queryCount-$answeredCount)."\n";

In reply to How to process with huge data's by arivu198314

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.