#! /usr/bin/perl use strict ; use warnings ; my $prog = substr $0, rindex ( $0, '/' ) + 1 ; my $Usage = < ) { print "loop 1 $_" if $opt{d} ; chomp ; if ( /Physical Drives = (\d+)/ ) { $pds = $1 ; last ; } } Error "no count for 'Physical Drives'" unless defined $pds ; while ( ) { print "loop 2 $_" if $opt{d} ; last if /^EID:Slt\s+DID\s+State\s+DG/ ; } my $sink = ; my $cnt = 0 ; while ( ) { print "loop 3 $_" if $opt{d} ; chomp ; last if /^-------------------/ ; $cnt ++ if ( ( split ' ' ) [ 2 ] eq 'Onln' ) ; } close CMD ; ( $cnt > $pds ? undef : $pds - $cnt ) ; } my $res = 0 ; for my $arg ( @ARGV ) { my $bads = get_bad_pds ( $arg ) ; print "$arg : bad pds $bads\n" if $opt{v} ; $res += $bads ; } printf "%s\n", $res ;