in reply to
Re: Re: Can I match a range from an array?
in thread Can I match a range from an array?
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