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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |