|There's more than one way to do things|
Re: Re: Re: Re: Can PERL know a line without matching?by brassmon_k (Sexton)
|on Jul 31, 2001 at 01:57 UTC||Need Help??|
Well I figured it out now with your guys help. It's complete. Well the script isn't but the know-how of it is. I read about $/ and $. and $* in a book but I didn't know how to make them work and I knew that is what I needed. I was lacking the split line with @lines that was my downfall. I didn't know how to tell PERL what the newline was but I see from your entries how to do it. The damn book didn't tell me I needed to do that. Anyway I'll post the script below. It's really rough as of right now because I haven't touched it up that much. It doesn't have warnings on or anything at all but I'll fix that. I was just testing. The tests all came back true. Everything is cool. Here is the script.
Well as you can see I got the script to only print off the lines I wanted when it finds the phone number or $msisdn and the $cell line. Well I have a lot more lines to add that aren't in there but the MSTerminating block should give you the best idea of what I was trying to accomplish and finally did. It works seamlessly right now. PERL can do anything! Here's the reason I wanted to rewrite this into PERL. One for easy maintenance and updates and 2 to rewrite something a former employee wrote that in my opinion being a disliker of AWK is a hideous script.
Here it is.
I rewrote some of it such as to get it to read STANDARD IN before you had to manually enter the msisdn number by editing the script and inserting the number you wanted in a msisdn variable. Then the output is sent to a file. Otherwise all the AWK syntax is from a former employee. I know what the scripts accomplishing but I'll be damned if I can read AWK or alter this script to get it to do what I want so as much as I hate reinventing the wheel it was for the best. I'll give him this he is good with AWK because that's the only language he uses. I still think it sucked.
The only downside of this script is I got a list of cell sites (The thing mentioned in $cell = "Blah") and they are to the BASE 10 and they are a separate list that gives the city code of the cell site which is in BASE 16.
For example: MAD023A 310-64-1101-20231 <--This is the BASE 10 form and is represting our 23rd cell site sector in Madison Wisconsin, It's one of the cell sites a big list of them.
Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'4F07 <--This example is the same exact thing to the BASE 16 which is in the text that I go through.
So in the end I want it to print --> Cell ID for First Cell: MCC: 310 MNC: 64 LAC: x'44D CI: x'MAD023A' as in the script.
Now I read in the 3rd Edition Perl Programming that their is a base class/object but it's definition is devoid of any relation to number bases just as HEX isn't mentioned. I'm wondering is their an easy way to just tell PERL the following: If you match x'4F07' on $lines5 of "MSTerminating" :(
Extreme not smily face because I just realized this is going to have to be a manual process either way I do it. Reason I say that is Bcuz my boss wants it printed out as I have it in the script otherwise I'd just print the appropriate line from the file that contains the city name and BASE 10 code.
Thanks so much. This is the best PERL FORUM on Earth and on the net. Thanks bikeNomad & thanks DA or Dan
You guyz are cool.
I'll check up on this see if you guys throw in any pointers. THANKS!
David M. Hagens