Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
code , creates an array of hashrefs
#!/usr/bin/perl -- use strict; use warnings; use constant qw{ DEBUG 0 }; { my $tell = tell DATA; my $curr_stack = []; my @prev_stack; my @obj; while(<DATA>){ next if /^\s*$/; s/\s+$//g; s/^\s+//g; DEBUG&& warn ">> $_ \n"; if(/^{$/){ push @$curr_stack,[]; push @prev_stack, $curr_stack; $curr_stack = $curr_stack->[-1]; DEBUG&& warn '{{{ @prev_stack == ' , 0 + @prev_stack; } elsif( /^}$/ ){ $curr_stack = pop @prev_stack; DEBUG&& warn '}}} @prev_stack == ' , 0 + @prev_stack; if( not @prev_stack ){ # ['CME20CP6.CallDataRecord.uMTSGSMPLMNCallDataRecord' => [...] ] # push @obj, hashbytwo($curr_stack); push @obj, hashbytwo($curr_stack->[-1]); #[...] } } else { if( / : / and /^\s*(.+?)(\s\:\s)(.+?)\s*$/ ){ push @$curr_stack, $1, $3 ; } else { push @$curr_stack, $_; } } } use Data::Dumper; print "\n",Data::Dumper->new([@obj]) ->Indent(1)->Sortkeys(1)->Dump,"\n"; print "Number of CDRs ", scalar(@obj),"\n"; printf "%s,%s,%s\n",#<<<<<<<<<<<<<<<<<<<<<<<<<<<# $_->{sCFChargingOutput}{callIdentificationNumber},#<# $_->{sCFChargingOutput}{exchangeIdentity},#<<<<<<<<<# $_->{sCFChargingOutput}{gSMCallReferenceNumber},#<<<# for @obj;#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<# seek DATA, $tell,0; } sub hashbytwo { my $h = shift; my %n; for( my $ix = 0; $ix < $#$h; $ix += 2 ){ #DEBUG&& warn " ref(", ref($$h[$ix+1] ), ") ", $$h[$ix+1] , " "; $n{$$h[$ix]}= ref $$h[$ix+1] ? hashbytwo($$h[$ix+1]): $$h[$ix+ +1] ; } return \%n; } __DATA__ CME20CP6.CallDataRecord.uMTSGSMPLMNCallDataRecord { sCFChargingOutput { callIdentificationNumber : '6CBFD7'H exchangeIdentity : "DWLCCN6" gSMCallReferenceNumber : '9103770001'H switchIdentity : '0001'H recordSequenceNumber : '39D42E'H date : '1409071F'H } eventModule { iNServiceDataEventModule { chargePartySingle : 'aPartyToBeCharged (0)' genericChargingDigits { [0] : '2000'H [1] : '011351'H [2] : '223A941400'H [3] : '233A940209'H [4] : '043A2000'H [5] : '0542'H [6] : '2600'H [7] : '2700'H [8] : '080290701391620122'H [9] : '2A02'H [10] : '72000000000000000000000000'H [11] : '730000000000000000041F'H [12] : '7400000000'H [13] : '3502'H } genericChargingNumbers { [0] : '0003136985138324'H [1] : '010413198935930920'H [2] : '0203136985138324'H [3] : '038290905893701402'H [4] : '0B000002000000'H } serviceFeatureCode : '0002'H timeForEvent : '131A01'H } } } CME20CP6.CallDataRecord.uMTSGSMPLMNCallDataRecord { sCFChargingOutput { callIdentificationNumber : '6CC99C'H exchangeIdentity : "DWLCCN6" switchIdentity : '0001'H recordSequenceNumber : '39D42F'H date : '1409071F'H } eventModule { iNServiceDataEventModule { chargePartySingle : 'bPartyToBeCharged (1)' genericChargingDigits { [0] : '2002'H [1] : '010359'H [2] : '023A8207'H [3] : '033A8207'H [4] : '043A0000'H [5] : '0506'H [6] : '2600'H [7] : '2704'H [8] : '080290701391622322'H [9] : '2A02'H [10] : '72000000000000000000000000'H [11] : '730000000000000000001F'H [12] : '3500'H } genericChargingNumbers { [0] : '0003138935167173'H [1] : '028210850000'H [2] : '0303138935167173'H [3] : '06041319'H } serviceFeatureCode : '0002'H timeForEvent : '131A20'H } } }
output
$VAR1 = { 'eventModule' => { 'iNServiceDataEventModule' => { 'chargePartySingle' => '\'aPartyToBeCharged (0)\'', 'genericChargingDigits' => { '[0]' => '\'2000\'H', '[10]' => '\'72000000000000000000000000\'H', '[11]' => '\'730000000000000000041F\'H', '[12]' => '\'7400000000\'H', '[13]' => '\'3502\'H', '[1]' => '\'011351\'H', '[2]' => '\'223A941400\'H', '[3]' => '\'233A940209\'H', '[4]' => '\'043A2000\'H', '[5]' => '\'0542\'H', '[6]' => '\'2600\'H', '[7]' => '\'2700\'H', '[8]' => '\'080290701391620122\'H', '[9]' => '\'2A02\'H' }, 'genericChargingNumbers' => { '[0]' => '\'0003136985138324\'H', '[1]' => '\'010413198935930920\'H', '[2]' => '\'0203136985138324\'H', '[3]' => '\'038290905893701402\'H', '[4]' => '\'0B000002000000\'H' }, 'serviceFeatureCode' => '\'0002\'H', 'timeForEvent' => '\'131A01\'H' } }, 'sCFChargingOutput' => { 'callIdentificationNumber' => '\'6CBFD7\'H', 'date' => '\'1409071F\'H', 'exchangeIdentity' => '"DWLCCN6"', 'gSMCallReferenceNumber' => '\'9103770001\'H', 'recordSequenceNumber' => '\'39D42E\'H', 'switchIdentity' => '\'0001\'H' } }; $VAR2 = { 'eventModule' => { 'iNServiceDataEventModule' => { 'chargePartySingle' => '\'bPartyToBeCharged (1)\'', 'genericChargingDigits' => { '[0]' => '\'2002\'H', '[10]' => '\'72000000000000000000000000\'H', '[11]' => '\'730000000000000000001F\'H', '[12]' => '\'3500\'H', '[1]' => '\'010359\'H', '[2]' => '\'023A8207\'H', '[3]' => '\'033A8207\'H', '[4]' => '\'043A0000\'H', '[5]' => '\'0506\'H', '[6]' => '\'2600\'H', '[7]' => '\'2704\'H', '[8]' => '\'080290701391622322\'H', '[9]' => '\'2A02\'H' }, 'genericChargingNumbers' => { '[0]' => '\'0003138935167173\'H', '[1]' => '\'028210850000\'H', '[2]' => '\'0303138935167173\'H', '[3]' => '\'06041319\'H' }, 'serviceFeatureCode' => '\'0002\'H', 'timeForEvent' => '\'131A20\'H' } }, 'sCFChargingOutput' => { 'callIdentificationNumber' => '\'6CC99C\'H', 'date' => '\'1409071F\'H', 'exchangeIdentity' => '"DWLCCN6"', 'recordSequenceNumber' => '\'39D42F\'H', 'switchIdentity' => '\'0001\'H' } }; Number of CDRs 2 '6CBFD7'H,"DWLCCN6",'9103770001'H Use of uninitialized value in printf at test.pl line 65, <DATA> line 8 +9. '6CC99C'H,"DWLCCN6",

In reply to Re: String Search by Anonymous Monk
in thread String Search by kallol.chakra

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (13)
    As of 2014-04-16 20:51 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (434 votes), past polls