next if /^robot/; $count++; system( ... ); #### my $drive; my $count = 0; open( LIST, "tpconfig -l|" ) or die $!; while() { ($drive) = unpack '@0 A8',$_; next unless /^drive/; (system("tpconfig -delete -drive -index ${count}") == 0) or print "Error deleting: $?"; $count++; }