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
In reply to Re: Re: Re: Can I match a range from an array?
by rchiav
in thread Can I match a range from an array?
by brassmon_k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |