in reply to Re: Re: Can I match a range from an array?
in thread Can I match a range from an array?
Here's what I understand:
-You have a line that has a number at the end of it that signifies something.
-You want to print something depending on the number.
-I'm assuming that what you want to print is the name of the cell site.
Soooo.. What I would do is the following..
Now.. if the regex confuses you, I'd suggest spending a little time with perlre. What this basically does it grabs the last part of the string that you said is variable. Then it takes that and looks it up in the hash. Now this is a very simple example, without error checking and the other various things that you should have in there. You need to take into account if there's no entry in the hash... and how you deal with that.#!/usr/bin/perl -w use strict; #putting the line in question into $_ for this example. $_ = "Cell ID for Last Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'503E +"; #create our hash of 'site codes' => 'text to print' my %cells = ('207B' => 'Miami', '432F' => 'Buffalo', '443R' => 'Whatever you want for cell site 443R', '503E' => 'Portland, OR' ); if (/CI: x'(\w+)$/) { print "Cell site is $cells{$1}.\n"; }
Hope this helps..
Rich
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Can I match a range from an array?
by dragonchild (Archbishop) on Aug 03, 2001 at 19:21 UTC | |
|
Re: Re: Re: Re: Can I match a range from an array?
by brassmon_k (Sexton) on Aug 03, 2001 at 22:33 UTC | |
by rchiav (Deacon) on Aug 03, 2001 at 23:08 UTC | |
by brassmon_k (Sexton) on Aug 04, 2001 at 00:18 UTC |