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 !