# contents of file: ! blah ! blah blah ! # start to grab section here with start (/interface/) interface GigabitEthernet1/1/2 description PC Trunk switchport trunk encapsulation dot1q switchport trunk native vlan 100 switchport mode trunk queue-set 2 priority-queue out mls qos trust dscp storm-control broadcast level 1.00 storm-control multicast level 1.00 spanning-tree guard loop channel-protocol lacp channel-group 1 mode active ! # ^ end section with (/!/) # ignore entire block of data when after (/interface/) a (/shutdown/) is seen before (/!/)" interface GigabitEthernet1/1/3 shutdown ! interface GigabitEthernet1/1/4 shutdown ! interface TenGigabitEthernet1/1/1 ! interface TenGigabitEthernet1/1/2 #*** Begin of sad attempt PL *** #!/usr/bin/perl -w # use strict; use warnings; my $CONFIGFILE = $ARGV[0]; print "$CONFIGFILE\n"; open(FILE, $CONFIGFILE) || die "file not found\n"; while () { if ($_ =~/^interface/../shutdown/) { next; } if ($_ =~/^interface/../!/) { print $_; } }