CJXJ220 has asked for the
wisdom of the Perl Monks concerning the following question:

Hi All,

I'm trying to cut my teeth on doing some pattern matching for a project I am working on for my job. As an exercise I have a written a script which telnets into a Cisco router and should return an inventory of all of the T1 interfaces on that device, making a note of which interfaces are voice PRIs.

To check for an interface I show the running configuration filtered by sections which contain the line controller T1. The problem I'm running into is the code is only returning the first match of the four interfaces that are on the router I am testing with.

It looks like you're using join incorrectly in your data collection loop. The join function uses the first item in its argument list as a separator which is placed between all the other items in the list. It looks like you're using it as a concatenator, which it will fail miserably at (at least the way you use it).

For example: print join('a','b') will print the letter b on your console, and print join('a','b','c') will print "bac". Normally, you'd use it like print join(", ", 'a', 'b','c') to get a nicely formatted list: "a, b, c".

The \G modifier was preventing the subsuequent matches. I had included it because to my understanding it would allow the next m// to start where the previous had left off, but I guess that only applies if you are also using the global match operator \g. Once that was removed I just had to make a few tweaks to get the output formatted the way I wanted.