I want the script to check the file for string "Response Queue Size: 0", and if this string has other than numerical 0, I want this to be print to my screen.
open my $infile, '<', 'C:/Users/katragas/Desktop/apadmin_get_status_lo
+g.txt' or die $!;
while( <$infile> ) {
if( /Response Queue Size: (\d+)/ ) {
print unless $1 == 0;
}
}
Your specification is fairly clear now; you've outlined the criteria. The next step is to implement those criteria:
- Iterate over the lines of the file.
- If a line matches "Response Queue Size: ", followed by a number, this is a line of interest.
- If that number turns out to not be zero, print the line to your screen.
The code I provided above follows those three steps: The while loop iterates over the file, the 'if' statement looks for a pattern of interest, and the 'print unless' statement prints the line unless that line of interest has a number equal to zero associated with it.