1 #!/usr/bin/perl -w 2 3 use strict; 4 5 my $infile = './count.in'; 6 my $vlan = "0"; 7 my $up = "0"; 8 my $down = "0"; 9 my $shut = "0"; 10 11 { 12 local $/ = undef; 13 open(IN, "<$infile") or die "Cannot open $infile: $!"; 14 my $filestring = ; 15 close IN or die "Cannot close $infile: $!"; 16 while ($filestring =~ /VLAN/g) { $vlan++ } 17 while ($filestring =~ /ifOperStatus.*up\(1\)/g) { $up++ } 18 while ($filestring =~ /ifOperStatus.*down\(2\)/g) { $down++ } 19 while ($filestring =~ /ifAdminStatus.*down\(2\)/g) { $shut++ } 20 } 21 22 my $live = ($up - $vlan); 23 my $total = ($live + $down); 24 25 print "$vlan VLAN(s)\n"; 26 print "$total physical ports\n"; 27 print "$live active port(s)\n"; 28 print "$down inactive port(s)\n"; 29 print "$shut disabled port(s)\n";