Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
OK that is so cool that you helped me. I finally got it but yet I don't. My brain block went away and I figured it out. Haven't gotten to much sleep lately. Here it is an almost working version that does everything I want. Now what I can't figure out is the fact that for the if statement you know if ( $cellsite{cell} ) and if ( $cellsite{cell1} ) it's A: obviously finding the Cell ID lines because it prints them out but the problem is B: The "if" statements are supposed to match up with the right "Cell ID" line and only print out the value for that key. My problem is that when I put in the phone number to limit the search results and the value for the key is the "Cell ID MAD023" one it still will print the "Cell ID APPL03". See their are 2 "MSTerminating" record blocks in the file it searches through each have 2 different numbers and 2 different "Cell ID lines" the problem is though that it prints both values for one phone number. What am I doing wrong. The output of the script I'll place below the script. I'm not that familiar with voting here cuz I just hit level 2 today and that (++) or (-) radio buttons above our entries (Didn't see that on level one) but I can give you guys like
++ points right? If that's the case you guys are getting em. I'm just double checking with you guys. Anyway here's the code.
#!/usr/bin/perl -w use strict; my $msisdn; my $cell; my %cellsite; my $lastHeading; my $para; my @lines; my $cell1; chomp($msisdn = <STDIN>); $cell = "Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x' +4F07"; $cell1 = "Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x +'APP03"; %cellsite = ("$cell", "Cell ID for First Cell: MCC: 310 MNC: 64 LAC: + x'44D CI: x'MAD023", "$cell1", "Cell ID for First Cell: MCC: 310 M +NC: 64 LAC: x'44D CI: x'APP03"); $/ = ""; # read paragraphs while ($para = <>) { @lines = split(/\n/, $para); if (@lines == 1) # A Heading { $lastHeading = $lines[0]; next; } if ($lastHeading eq "MSTerminating") { if ($lines[8] =~ m/$msisdn/) { if ( $cellsite{$cell} ) { print "$cellsite{$cell}\n"; } if ( $cellsite{$cell1} ) { print "$cellsite{$cell1}\n"; } print "MSTerminating\n"; print "\n"; print "$lines[8]\n"; print "$lines[4]\n"; } } elsif ($lastHeading eq "MSORIGINATING") { if ($lines[7] =~ m/$msisdn/) { print "MSORIGINATING\n"; print "\n"; print "$lines[7]\n"; # sixth line } } elsif ($lastHeading eq "TRANSIT") { if ($lines[7] =~ m/$msisdn/) { print "$lines[7]\n"; } } elsif ($lastHeading eq "mSOriginatingSMSinSMSIWMSC") { if ($lines[4] =~ m/$msisdn/) { print "$lines[4]\n"; } } }
Command line/Script output.
$ exp4.53 output #Command line 6082572086 #Command line OUTPUT Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'MAD023 Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'APP03 MSTerminating Calling Party Number: TON: NPI: 1 MSISDN: "phone number" MSC Identification: TON: 1 NPI: 1 MSISDN: "phone number"
So you can see my problem. For the phone number I looked up in this record block the "Cell ID" line has "4F07" at the end - So the script looks at the hash and prints out the appropriate garbage. However for the "Cell ID" line "503E" isn't there and that when translated to it's name is "APP03" so that shouldn't have printed but it did anyway even though that number isn't in the "Cell ID" line for this particular record block. So it's printing one line of garbage. What's the problem, I can't figure this out.

The Brassmon_k

In reply to Re: Re: Re: Can I match a range from an array? by brassmon_k
in thread Can I match a range from an array? by brassmon_k

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (4)
    As of 2018-07-23 02:30 GMT
    Find Nodes?
      Voting Booth?
      It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

      Results (459 votes). Check out past polls.