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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |