#!/usr/bin/perl use strict; use warnings; $/ = "!\n"; while( ) { /^interface (.*\n)(?: .*\n)*? spanning-tree guard root/ and print $1; } __DATA__ ! interface other-one switchport access vlan 300 switchport mode access switchport port-security maximum 130 switchport port-security switchport port-security aging time 2 switchport port-security aging type inactivity no logging event link-status speed 100 duplex full srr-queue bandwidth share 1 60 30 10 srr-queue bandwidth shape 3 0 0 0 mls qos trust device cisco-phone storm-control broadcast level pps 1k storm-control multicast level pps 2k storm-control action shutdown storm-control action trap spanning-tree portfast spanning-tree bpduguard enable ! ! interface FastEthernet1/0/3 switchport access vlan 300 switchport mode access switchport port-security maximum 130 switchport port-security switchport port-security aging time 2 switchport port-security aging type inactivity no logging event link-status speed 100 duplex full srr-queue bandwidth share 1 60 30 10 srr-queue bandwidth shape 3 0 0 0 mls qos trust device cisco-phone storm-control broadcast level pps 1k storm-control multicast level pps 2k storm-control action shutdown storm-control action trap spanning-tree portfast spanning-tree bpduguard enable spanning-tree guard root ! ! interface other-two switchport access vlan 300 switchport mode access switchport port-security maximum 130 switchport port-security switchport port-security aging time 2 switchport port-security aging type inactivity no logging event link-status speed 100 duplex full srr-queue bandwidth share 1 60 30 10 srr-queue bandwidth shape 3 0 0 0 mls qos trust device cisco-phone storm-control broadcast level pps 1k storm-control multicast level pps 2k storm-control action shutdown storm-control action trap spanning-tree portfast spanning-tree bpduguard enable ! ! interface FastEthernet1/0/4 switchport access vlan 300 switchport mode access switchport port-security maximum 130 switchport port-security switchport port-security aging time 2 switchport port-security aging type inactivity no logging event link-status speed 100 duplex full srr-queue bandwidth share 1 60 30 10 srr-queue bandwidth shape 3 0 0 0 mls qos trust device cisco-phone storm-control broadcast level pps 1k storm-control multicast level pps 2k storm-control action shutdown storm-control action trap spanning-tree portfast spanning-tree bpduguard enable spanning-tree guard root ! #### FastEthernet1/0/3 FastEthernet1/0/4