in reply to Re^2: Create output from Perl hash
in thread Create output from Perl hash
which prints:use strict; use warnings; my $line; while (<DATA>) { $line = $1 if /^\s*MSISDN=(\d+);/; 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"; __DATA__ <BEGINFILE> <SUBBEGIN IMSI=232191400010332; MSISDN=436906901235; CF=CFU-ALL-PROV-NONE-YES-NO-NONE-YES-65535-NO-NO-NO-NO-NO-NO-NO-NO +-NO-NO; CF=CFB-ALL-PROV-NONE-YES-YES-NONE-YES-65535-NO-NO-NO-NO-NO-NO-NO-N +O-NO-NO; CF=CFNRY-ALL-PROV-NONE-YES-YES-NONE-YES-65535-NO-NO-NO-NO-NO-NO-NO +-NO-NO-NO; CF=CFNRC-ALL-PROV-NONE-YES-NO-NONE-YES-65535-NO-NO-NO-NO-NO-NO-NO- +NO-NO-NO; CF=CFD-TS10-ACT-91496903000-YES-YES-25-YES-65535-YES-YES-NO-NO +-NO-YES-YES-YES-YES-NO; <SUBEND
Please note that your specification and your example output are inconsistent. Your spec says "1/1/1/0" (three 1s) and "1/1/1/49690300" (three 1s, and the trailing 0 removed from 91496903000), and your example says "1/1/1/1/0" (four 1s, not three) and "1/1/1/1/91496903000" (four 1s and the complete number 91496903000). You'll have to adjust the code in accordance with your actual needs.436906901235,CFU-ALL-PROV-1/1/1/0,CFB-ALL-PROV-1/1/1/0,CFNRY-ALL-PROV- +1/1/1/0,CFNRC-ALL-PROV-1/1/1/0,CFD-TS10-ACT-1/1/1/91496903000
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Create output from Perl hash
by gbwien (Sexton) on Feb 13, 2018 at 14:29 UTC | |
by Laurent_R (Canon) on Feb 13, 2018 at 16:46 UTC | |
by gbwien (Sexton) on Feb 14, 2018 at 10:31 UTC | |
by Laurent_R (Canon) on Feb 14, 2018 at 11:24 UTC | |
by gbwien (Sexton) on Feb 14, 2018 at 13:15 UTC | |
| |
by poj (Abbot) on Feb 13, 2018 at 17:40 UTC | |
Re^4: Create output from Perl hash
by gbwien (Sexton) on Feb 13, 2018 at 14:38 UTC | |
Re^4: Create output from Perl hash
by gbwien (Sexton) on Feb 13, 2018 at 14:06 UTC | |
by pryrt (Abbot) on Feb 13, 2018 at 14:22 UTC |