my $state; open (datei ,"$AUSGABE "); while(my $line = ) { if($line =~ m/^SP\s+\w+\s+\w+\s+\w+\s+(\w+)/) { $state = $1; if($1 =~ m/Enabled/) { $error_counter = 0; } else { $error_counter++; } } } close (datei); if($error_counter == 0) { print "O.K.: Write Cache State $state \n"; exit (0); } else { print "Critical: Write Cache State $state \n"; exit (2) }