in reply to Re: Re: Can I match a range from an array?
in thread Can I match a range from an array?
Command line/Script output.#!/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"; } } }
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.$ 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"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Can I match a range from an array?
by snafu (Chaplain) on Aug 04, 2001 at 00:14 UTC | |
by brassmon_k (Sexton) on Aug 04, 2001 at 00:33 UTC |