Depending on the exact format of your text file you may be able to reduce the code to something like this ;
#!perl
use strict;
open FH_SECOND,"<",$ARGV[0] or die $!;
my @setting = ('Port Speed','Duplex Setting','Switchport Access Mode',
+'Spanning Tree Mode');
my $line1 = <FH_SECOND>;
if ($line1 =~ /description xxxxxxxxx/){
while (<FH_SECOND>){
my $msg = 'Gigabit '.shift @setting;
if(/speed 1000|duplex full|switchport mode access|spanning-tree po
+rtfast/){
print $msg." is OK!!!\n";
} else {
print $msg." is WRONG!!!\n";
}
}
} else {
print "The Configuration File $ARGV[0] is NOT the RIGHT FILE \n";
}
close(FH_SECOND);
# test file
#description xxxxxxxxx
#speed 1000
#duplex full
#switchport mode access
#spanning-tree portfast
poj |