Hi thanos1983 An example of an input file is below, the file starts with <BEGINFILE> and ends with <ENDFILE>. To accommodate for this I added to your while loop

chomp; next if /^<ENDFILE>/; next if /^<BEGINFILE>/; next if (/<BEGINFILE>/);
<BEGINFILE> <SUBBEGIN IMSI=0000000000000; MSISDN=4411287879987; DEFCALL=TS11; CURRENTNAM=BOTH; CAT=COMMON; TBS=TS11&TS12&TS21&TS22; VLRLIST=10; SGSNLIST=10; MSC=445454578142; SGSN=44546578751; SMDP=MSC; CB=BAOC-ALL-PROV; CB=BOIC-ALL-PROV; CB=BOICEXHC-ALL-PROV; CB=BICROAM-ALL-PROV; IMEISV=000011222554545; CW=CW-ALL-PROV; 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-9112345678-YES-YES-25-YES-65535-YES-YES-NO-NO-NO-Y +ES-YES-YES-YES-NO; CONTROL=SUB; WPA=0; GS=HOLD&MPTY&ECT&CLIR&CLIP; CLIRES=TEMPALLOW; CLIPOC=NO; ARD=PROV; SUBRES=ALLPLMN; IST_ALERT_TIMER=120; IST_ALERT_RESPONSE=2; SUB_AGE=0; UPL_TIME=1447410859; PURGE_TIME_ATMSC=1505118714; GPRSUPL_TIME=1446458542; PURGE_TIME_ATSGSN=1447506399; MIMSI=564567467234544-ONELIVE-1-1-1-0-0; MIMSI=123245748722558-ONELIVE-2-2-1-0-0; SID=64672546767; UNRI=NO; UNRR=100; URRP_MME=REACHABLE; URRP_SGSN=NOT_REACHABLE; MCSISTATE=YES; CLRBSG=CLIP-YES-NO-NO-NO-NO; UPLCSLCK=NO; UPLPSLCK=NO; DEFOFAID=10; EPS_PROFILE_ID=1; TGPPAMBRMAXUL=50000000; TGPPAMBRMAXDL=150000000; ARD_EXT=NULL-NULL-NULL-N3GPPNOTALLOWED; SUB_DYN_EPS_ID=1; MMEHOST=graz1.mme.epc.mnc003.mcc232.3gppnetwork.org; MMEREALM=epc.mnc003.mcc232.3gppnetwork.org; EPS_IMEI=866695022931980; EPS_IMEISV=00; MMEFEATURELIST=ALL_APN-HPLMN_APN-VPLMN_APN-NULL-NULL-NULL-NULL-NUL +L-NULL-REGSUB-TRACE-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL +-NULL-NULL-NULL-NULL-NULL-TADS_DATA_RETR; SGSNFEATURELIST=NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL- +NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL-NULL +-NULL-NULL-NULL; MMEULRFLAG=SING_REG_IND-S6AORS6D_IND-SKIP_SUBDATA-NULL-NULL-NULL-P +S_LCS_NOTSUPP; SGSNULRFLAG=NULL-NULL-NULL-NULL-NULL-NULL-NULL; MMETIMESTAMP=1447506399; S4SGSNTIMESTAMP=0; FRAUDTPL_ID=10; HLR_INDEX=1; LTEAUTOPROV=NO; PSSER=1-1-10-1-NONE-DYNAMIC-00000000; EPSSER=1-10-10-1-NONE-DYNAMIC-00000000-1; MPS=NO; ODBIC=BAIC; ODBOC=BAOC; ODBROAM=ODBOHC; ODBPRC=ENTER; ODBPRC=INFO; ODBPLMN=NONE; ODBPOS=NOBPOS-BOTH; ODBECT=OdbAllECT; ODBDECT=YES; ODBMECT=YES; ODBPREMSMS=YES; ODBADULTSMS=YES; <SUBEND <ENDFILE>

The output should look like this for this record,couple of regex do work on the output CFU-ALL-PROV-NONE becomes CFU-ALL-PROV-1/1/1/0,CFB-ALL-PROV-NONE becomes CFNRY-ALL-PROV-1/1/1/0,,CFNRY-ALL-PROV-NONE becomes CFNRY-ALL-PROV-1/1/1/0, CFD-TS10-ACT-9112345678 becomes CFD-TS10-ACT-12345678 The ouput consists of the following values, MSISDN,CB,CF and ODB values.

4411287879987,BAOC-ALL-PROV,BOIC-ALL-PROV,BOICEXHC-ALL-PROV,BICROAM-ALL-PROV,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/12345678,BAIC,BAOC,ODBOHC,ENTER,INFO,NONE,NOBPOS-BOTH,OdbAllECT,YES,YES,YES,YES

Data::Dumper shows the following but CFNRC, CFB, CFU and CFNRY exist in the input file so the values for these keys are incorrect

$VAR1 = { 'ODBOC' => 'BAOC', 'ODBIC' => 'BAIC', 'CF' => { 'CFNRC' => 'CfnrncNotSet', 'CFB' => 'CfbNotSet', 'CFD' => 'CFD-TS10-ACT-9112345678-YES-YES-25-YES-6 +5535-YES-YES-NO-NO-NO-YES-YES-YES-YES-NO', 'CFU' => 'CfuNotSet', 'CFNRY' => 'CfnrnyNotSet' }, 'MSISDN' => '4411287879987' };
Thanks again

In reply to Re^4: Grouped Regular Expression not set assign default value by gbwien
in thread Grouped Regular Expression not set assign default value 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.