Hi, Here is my piece of code.
#!/usr/bin/perl my $logFile = $ARGV[0]; die "usage: $0 <logFile>" unless $logFile; die "Logfile $logFile doesn't exist" unless -f "$logFile"; my %no_of_questions; my %timestamp; open (FP,"<$logFile") or die "unable to open file $!" ; @records=<FP>; chomp(@records); for($index=0;$index<@records;$index++) { if($records[$index] =~ /^(.*)INFO:.*Entering QnAModule::authen +ticate/) { #printf "in INFO:.*Entering QnAModule::authenticate\n"; $Time_Stamp = $1; die "Some error in search_for_username_and_no_of_questions +" if (search_for_username_and_no_of_questions() == -1); die "Some error in end_block" if (end_block() == -1); last; } } sub search_for_username_and_no_of_questions { printf "inside search_for_username_and_no_of_questions\n"; for($index=0;$index<@records;$index++) { if ($records[$index] =~ /userName :\[(..*)\]/) { #printf "in user name identification \n"; $User_Name = $1; $User_Name =~ s/\s+//g; for(;$index<@records;$index++) { if ($records[$index] =~ /Set of questions\(bit +map\) selected : (\d+)/) { #printf "in set of questions\n"; $Bitmap_Number_For_Questions = $1; $no_of_questions{$User_Name}=$Bitmap_Numbe +r_For_Questions; $timestamp{$User_Name}=$Time_Stamp; printf "DETAIL: LINE NO: $index\n"; printf "$Time_Stamp,$User_Name,$Bitmap_Num +ber_For_Questions\n"; } } } } return -1; } sub end_block { printf "Inside end_block\n"; for($index=0;$index<@records;$index++) { if($records[$index] =~ /QNA Step.*AUTH IN PROGRESS/) { printf "DETAIL: auth in progress\n"; for(;$index<@records;$index++) { if ($records[$index] =~ /ArAuthFrameworkImpl::doPostAu +th.*Authentication mechanism returned \[(..*)\] for AuthIdentity \[(. +.*)\]/) { #printf "done one request \n"; #printf "$records[$index]\n"; my $return_code = $1; my $temp_user = $2; $temp_user =~ s/\s+//g; printf "user = $temp_user\n"; if(exists($no_of_questions{$temp_user})) { if ($return_code == 0) { printf "$no_of_questions{$temp_user} , $ti +mestamp{$temp_user} , \"Success\" \n"; } elsif ($return_code > 1) { printf "$no_of_questions{$temp_user} , $ti +mestamp{$temp_user} , \"Failure\" \n"; } for(;$index<@records;$index++) { if ( ($records[$index] =~ /Prepared to Sen +d OK/) || ($records[$index] =~ /Sending Invalid credential/) ) { printf "end of file\n"; } } } } } } } return -1; }
The script is not going in function end_block(). I am not able to understand why it is happening. here is the sample data-
INFO:Entering QnAModule::authenticate userName :[prasanna] Set of questions(bitmap) selected : 13 QNA Step.*AUTH IN PROGRESS ArAuthFrameworkImpl::doPostAuth.*Authentication mechanism returned [he +llo] for AuthIdentity [prasanna] Prepared to Send OK Sending Invalid credential
Thanks NT

In reply to Problem in script by namishtiwari

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.