Hello again gbwien,

I was under the impression that you want the opposite output. This should do what you want:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use feature 'say'; open (my $fhIn, '<', "in.txt") or die "Can not open 'in.txt': $!"; open (my $fhOut, '>', "out.txt") or die "Can not open 'out.txt': $!"; my %hash = (); my $count = 0; while (<$fhIn>) { chomp; next if (/<BEGINFILE>|<ENDFILE>/); if (/<SUBBEGIN/) { $count = 1; } elsif (/<SUBEND/) { $count = 0; } elsif ($count) { my @tmp = split /=/; chop $tmp[1]; if (/MSISDN/) { $hash{MSISDN} = $tmp[1]; } elsif (/ODBIC/) { $hash{ODBIC} = $tmp[1]; } elsif (/ODBOC/) { $hash{ODBOC} = $tmp[1]; } elsif (/CF/) { my @cf = split /-/, $tmp[1]; if (index($tmp[1], 'CFB-ALL-PROV-NONE') != -1){ $hash{'CF'}{$cf[0]} = $tmp[1]; } else { $hash{'CF'}{$cf[0]} = 'CfbNotSet'; } if (index($tmp[1], 'CFU-ALL-PROV-NONE') != -1){ $hash{'CF'}{$cf[0]} = $tmp[1]; } else { $hash{'CF'}{$cf[0]} = 'CfuNotSet'; } if (index($tmp[1], 'CFNRY-ALL-PROV-NONE') != -1){ $hash{'CF'}{$cf[0]} = $tmp[1]; } else { $hash{'CF'}{$cf[0]} = 'CfnrnyNotSet'; } if (index($tmp[1], 'CFNRC-ALL-PROV-NONE') != -1){ $hash{'CF'}{$cf[0]} = $tmp[1]; } else { $hash{'CF'}{$cf[0]} = 'CfnrncNotSet'; } $hash{'CF'}{$cf[0]} = $tmp[1]; } } if ($count == 0) { print Dumper \%hash; if (exists $hash{MSISDN}) { say $fhOut "Update Command <".$hash{MSISDN}.">,".$hash{ODBIC}. +",".$hash{ODBOC}.""; } else { say $fhOut "Update Command MSISDN=notSet,".$hash{ODBIC}.",".$h +ash{ODBOC}.""; } delete $hash{MSISDN}; delete $hash{ODBIC}; delete $hash{ODBOC}; delete $hash{CF}; } } close ($fhIn) or warn "Could not close 'in.txt': $!"; close ($fhOut) or warn "Could not close 'out.txt': $!"; __END__ $ perl test.pl $VAR1 = { 'ODBIC' => 'BAIC', 'CF' => { 'CFU' => 'CFU-ALL-PROV-NONE-YES-NO-NONE-YES-65535- +NO-NO-NO-NO-NO-NO-NO-NO-NO-NO', 'CFD' => 'CFD-TS10-ACT-9112345678-YES-YES-25-YES-6 +5535-YES-YES-NO-NO-NO-YES-YES-YES-YES-NO', 'CFB' => 'CFB-ALL-PROV-NONE-YES-YES-NONE-YES-65535 +-NO-NO-NO-NO-NO-NO-NO-NO-NO-NO', 'CFNRC' => 'CFNRC-ALL-PROV-NONE-YES-NO-NONE-YES-65 +535-NO-NO-NO-NO-NO-NO-NO-NO-NO-NO', 'CFNRY' => 'CFNRY-ALL-PROV-NONE-YES-YES-NONE-YES-6 +5535-NO-NO-NO-NO-NO-NO-NO-NO-NO-NO' }, 'MSISDN' => '4411287879987', 'ODBOC' => 'BAOC' };

Hope this helps. BR / Thanos

Seeking for Perl wisdom...on the process of learning...not there...yet!

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