Calling this entire fragment of data a 'block,' just to put a name to it, and presuming for the moment that the string 'PCSPLMNCallDataRecord' identifies the beginning of every such block of data, and further that 'mSTerminating' is a label (say, like its type) that could be different in each such block, I might write something like this to read it into a perl data structure:
my %PCSPLMNCallDataRecords; my $type_name; # type of the block we're reading my $block = undef; # place for block values while ( <> ) { # get each line somehow chomp; # no leading spaces means new block if ( /^PCSPLMNCallDataRecord/ ) { $type_name = undef; # next we expect a type name $block = undef; } # 3 leading spaces signals 'type' of block follows elsif ( /^\s{3}(\S.*)\s+$/ ) { next if ( $typename || $block ); # before we're ready $type_name = $1; # (e.g., 'mSTerminating') $block = {}; # next we expect data } # six leading spaces indicates data line elsif ( /^\s{6}(\S+)\s+(.+)\s*$/ ) { next if (! $typename || ! $block ); # before we're ready # lefthand column is the 'property' name. after first whitespace, # rest is data with trailing whitespace trimmed my ($key, $val) = ($1, $2); # first line in this block if ( scalar keys %$block == 0 ) { # if we don't already have an array create for this type, create + one now $PCSPLMNCallDataRecords{$type_name} = [] if not exists $PCSPLMNC +allDataRecords{$type_name}; # no values added yet, add hashref to array for this type only f +or first line push @{$PCSPLMNCallDataRecords{$type_name}}, $block; } $block->{$key} = $val; # add data to block (e.g., ' +callIdentificationNumber' => "2487067'D") } } # now you have the following structure in %PCSPLMNCallDataRecords: %PCSPLMNCallDataRecords = ( 'mSTerminating' => [ # array of 'mSTermina +ting' records { callIdentificationNumber => '2487067\'D', relatedCallNumber => '2487060\'D', recordSequenceNumber => '7410342\'D', exchangeIdentity => '"MAPP01E 01178 +02"\'S', mSCIdentification => '1119207079800F +\'TBCD', cellIDForFirstCellCalled => # etc ... }, { #... next mSTerminating record ... } ], 'mSOtherType' => [ array of 'mSOtherType' records, . +.. ] ); # an array of hashes with all of the 'mSTerminating' records: my @mSTerminating = @{$PCSPLMNCallDataRecords{mSTerminating}}; # the first 'mSTerminating' record in the array my %mSTerminating = %{$mSTerminating[0]}; # OR my %mSTerminating = %{$PCSPLMNCallDataRecords{mSTerminating}[0]};
Hope this helps ...

dmm

Just call me the Anti-Gates ...

In reply to Re: Non-fixed data in record by dmmiller2k
in thread Non-fixed data in record by brassmon_k

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.