Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Matching a cisco interface config

by rubasov (Friar)
on Jan 12, 2010 at 11:55 UTC ( #816881=note: print w/ replies, xml ) Need Help??

in reply to Matching a cisco interface config

If you want to keep the regex based approach try the code below, and see 'perldoc perlre' for the meaning of /m and /s modifiers. (However I think BrowserUK's solution above is more lightweigth than this.)

#! /usr/bin/perl use strict; use warnings; my $config = do { local $/; <DATA> }; my @interfaces = ( $config =~ m/^interface.+?\n!\n/msgi ); foreach my $interface (@interfaces) { print $interface, "--\n"; } __DATA__ interface GigabitEthernet6/10 description TRUNK-KBV-SW001 switchport trunk encapsulation dot1q switchport trunk allowed vlan 1,30,31,45,156-158 switchport mode trunk switchport nonegotiate ! interface GigabitEthernet6/11 description Offices switchport access vlan 31 spanning-tree portfast ! interface GigabitEthernet6/12 !

Comment on Re: Matching a cisco interface config
Download Code
Replies are listed 'Best First'.
Re^2: Matching a cisco interface config
by FloydATC (Chaplain) on Jan 12, 2010 at 19:52 UTC
    I knew I was missing something, and the /s modifier was it, thank you!

    -- Time flies when you don't know what you're doing

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://816881]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (1)
As of 2015-10-10 09:05 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (255 votes), past polls