Please suggest if any Corrections Needed. [code] #!/usr/bin/perl
use 5.10.0; use strict; use warnings; #########################Pattern############################################ #U/A/S|Test| Test |Loop | Run |Pass |Fail | Arguments # | # | Name |Count|Count|Count|Count| #-----+----+---------------------------+-----+-----+-----+-----+----------- # | 72| Traffic Test | 1| 561| 560| 1| (none) ############################################################################ my $pattern; open (my $Log_file, '<', '/tmp/EO-PCPE-23-10GT') || die "Couldn't open /tmp/EO-PCPE-23-10GT\n\t $!"; while(<$Log_file>) { if($_ =~ m/^(.+?)\|(.+72)\|(.+?)\|(.+?)\|(.+[0-9]|[0-9]|[0-9])\|(.+[0-9]|[0-9]|[0-9])\|(.+?)\|(.+?)$/) { $pattern=$_; } } print "Pattern Found:\n$pattern"; my $uas=(split /\|/, $pattern)[0]; $uas =~ s/^\s+//; my $test=(split /\|/, $pattern)[1]; $test =~ s/^\s+//; my $test_name=(split /\|/, $pattern)[2]; $test_name =~ s/^\s+//; my $loop_count=(split /\|/, $pattern)[3]; $loop_count =~ s/^\s+//; my $run_count=(split /\|/, $pattern)[4]; $run_count =~ s/^\s+//; my $pass_count=(split /\|/, $pattern)[5]; $pass_count =~ s/^\s+//; my $fail_count=(split /\|/, $pattern)[6]; $fail_count =~ s/^\s+//; my $arguments=(split /\|/, $pattern)[7]; $arguments =~ s/^\s+//; print '-' x 30, "\n"; print " Test Data \n"; print '-' x 30, "\n"; print "UAS : $uas\n"; print "Test : $test\n"; print "Test Name : $test_name\n"; print "Loop Count : $loop_count\n"; print "Run Count : $run_count\n"; print "Pass Count : $pass_count\n"; print "Fail Count : $fail_count\n"; print "Arguments : $arguments\n"; print '-' x 30, "\n"; print " RESULTS \n"; print '-' x 30, "\n"; if($fail_count != 0 && $run_count >= 0) { print "Result: Fail\n"; } elsif($fail_count == 0 && $run_count > 0) { print "Result: Pass\n"; } [code] output-1 PASS condition ----------------------------------- Pattern Found: | 72| Traffic Test | 1| 561| 561| 0| (none) ------------------------------ Test Data ------------------------------ UAS : Test : 72 Test Name : Traffic Test Loop Count : 1 Run Count : 561 Pass Count : 561 Fail Count : 0 Arguments : (none) ------------------------------ RESULTS ------------------------------ Result: Pass output-2 FAIL condition ---------------------------------- Pattern Found: | 72| Traffic Test | 1| 561| 560| 1| (none) ------------------------------ Test Data ------------------------------ UAS : Test : 72 Test Name : Traffic Test Loop Count : 1 Run Count : 561 Pass Count : 560 Fail Count : 1 Arguments : (none) ------------------------------ RESULTS ------------------------------ Result: Fail On Thu, Jun 26, 2014 at 11:06 AM, Uday Vernekar <vernekaru...@gmail.com> wrote: > I got it thanks jim :) > > > On Wed, Jun 25, 2014 at 7:12 PM, Jim Gibson <j...@gibson.org> wrote: > >> >> On Jun 25, 2014, at 12:11 AM, Uday Vernekar <vernekaru...@gmail.com> >> wrote: >> >> > Dear Ron, >> >> You are better off addressing your questions to the entire mailing list, >> rather than asking information from one person. Ron is not obligated to >> help you and may not be available, but others may be willing to help you. >> >> > How wud i grep the string | 72| Traffic Test | 1| >> 561| from log file which is Very large. >> >> You would: >> >> 1. open the file for reading >> 2. read each line in the file >> 3. check each line for your desired pattern >> >> That is what grep does. By doing this in Perl, you save having to create >> another process. You can combine the step of finding the pattern and >> extracting information from the desired line. You can also quit after you >> have found the line you are seeking, if you only need to find one match; >> grep will continue to read the rest of the file looking for more matches. >> >> Let us know if you have problems with any of these steps. >> >> >> -- >> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >> For additional commands, e-mail: beginners-h...@perl.org >> http://learn.perl.org/ >> >> >> > > > -- > ********************************************************* > Don't ask them WHY they hurt you, > because all they'll tell you is lies and excuses. > Just know they were wrong, and try to move on. > ********************************************************** > -- ********************************************************* Don't ask them WHY they hurt you, because all they'll tell you is lies and excuses. Just know they were wrong, and try to move on. **********************************************************