|We don't bite newbies here... much|
Wow, thanks everybody, what a response..!!
In terms of updating to Perl 5.10 and using the Smart Match Operator. I did look into that but updating the Perl version wasn't really an option at the moment bc it is a production server and a bunch of things running depend on that. But I did want to try to use that at some point...
Thanks for the reply, The example you show is sort of what I was trying to achieve with the ranges, maybe I'll give that one a try as well. Thanks again!
Oh ok I gotcha... Bc it was working just not in the way I thought it would...? Thanks for the info.
Hey, that looks cool I'll have to look into that Module as well. Seems alot like the Acme::Tools Module that I eventually went with from toolic's suggestion... Thanks I'll have to download that Module.
That's a good one..! I like that! Don't know why I didn't think of that. Clean and simple, since the control structure, once it finds a match, it will drop out of the if/elsif clause which leads to not having to use a range to test on, but just one test instead... Cool thanks..!
Hey thanks for the reply. Sorry it took me a while to respond back but I decided to go with toolic's suggestion with the ACME::Tools solution... Works Good!
But in terms of a backstory. The thing I need this for is a script to run along side with MRTG and Interafce Templates to check which GigabitEthernet port it is and then separate them into groups to test for Backplane usage on a Cisco switch. Backplane is Bundeled ports (usually 8 consecutive one's) ranging from (Gi3/1<-->Gi3/48; Gi4/1<-->Gi4/48; ... all the way to ... Gi7/1<-->Gi7/48).
So basically some of the groups would be in ranges as follows... For example the range Gi3/1..Gi3/8 would be "Bundle-Gi3A", and Gi3/9..Gi3/16 would be "Bundle-Gi3B" all the way up to Bundle-Gi3F. As for Gi4 -to- Gi7 it would be the same Letters only difference would be the Gi number...
Here is my entire solution to the original question:
The original question had to do with the Subroutine "get_bundle()"
I know it's a SIMPLE program but here it is. Basically you just pass it the interface name (i.e. "Gi3/7") broken into two pieces, (1) the Gi number "Gi3" and (2) the reference number "7", which is passed from an MRTG Template/Script and then passed back to the Template to be added to the config ("cfg") file.
I'm SURE there is a 100 different ways to do this, but this works for my current situation...
I REALLLY want to thank all of you for your suggestions, it was MUCH MUCH more then I expected..!!
Thanks Again Everybody,