in reply to Re^4: String Search
in thread String Search

The print part I have commented..

Replies are listed 'Best First'.
Re^6: String Search
by Anonymous Monk on Aug 31, 2009 at 13:06 UTC
    I think you're having problems with the way you're parsing it, instead of putting all contents in a huge array that will crash your memory if crd logs are big enough. the standar approach is
    my $number_of_crds = 0; while(<INPUT_FILE>) { if ( $_ =~ /CME20CP6/) { $number_of_crds++; } ... ... }
    close(INPUT_FILE); and you should be able to use one while to do all parsing and extract the values with regular expressions for example, inside the first while
    if ( $_ =~ /callIdentificationNumber\s+:\s+\'(.+)\') { print "callIndentificationNumber: $1\n"; }
    In this case the regular expression is extended to extract the values inside quote symbols You're using global variables, I'd recomend you to use strict mode "use strict;" it will force you to define the scope of the variables, having global variables creates lots of parsing errors, i.e.: first record has a gSMCallReferenceNumber node so it loads variable $callIdentificationNumber with that value, if the following record ( or any of the following cdr records) don't have gSMCallReferenceNumber node and as $callIndentificationNumber is global you will have variable loaded with previous value.

      Hi,

      This is ok. I will surely use it. But main problem is that I can not use else for any "if". If I use else then it will work for every row in the data. Please help me..

      Regards