edited

I am studying your program and one question I would like to ask you is the following. If the line does not match an MSISDN=value pair e.g. MSISDN=433336901235;, I would like to write to the line MSISDN=0 and then to continue processing the next line, but I am not certain how to do that? This scenario could also occur for other entries other than MSISDN but if I can understand how an example would work I could apply this later on to other parts of the code

Looking at the input file again as an example:-

<BEGINFILE> <SUBBEGIN IMSI=231111400010332; MSISDN=433336901235; ..... .. . <BEGINFILE> <SUBBEGIN IMSI=231111400010339; <----MSISDN is missing I would like +to write MSISDN=0 to the output file ... .. .
use strict; use warnings; my $line; while (<DATA>) { if (/^\s*MSISDN=(\d+);/) { print "$line\n" if defined $line; $line = $1 ; } if (/\s*CF=([\w-]+?-(?:NONE|\d+))/) { my $add = $1; $add =~ s{(\d+)$}{1/1/1/$1}; $add =~ s{NONE}{1/1/1/0}; $line .= ",$add"; } } print "$line\n";

the output would look something like this

433336901235,....... additional entries

MSISDN=0,....... additional entries

Thanks you, graham


In reply to Re^11: Create output from Perl hash by gbwien
in thread Create output from Perl hash by gbwien

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.