I have 2 input files.
$> cat file1.txt
! This is a comment in file1.txt
// Another comment and below line is an empty line
SIR 8
TDI(03)
TDO(01)
MASK(03);
and
$> cat file2.txt
! This is a comment in file2.txt
// Another comment and below line is an empty line
sir 8 tdi(03) tdo(01) mask(03);
Now, I'm trying to write a script that would harvest all those 'sir' lines. This is what I have:
while(<>) {
# Skip over all lines that start with ! or are empty or start with //
next unless !/^!/ and !/^\s*$/ and !/^\s*\/\//;
# I'm using the modifier /i to be case insensitive
if(/sir\s+\d+\s+tdi\(\d+\)\s+tdo\(\d+\)\s+mask\(\d+\)\s*;/i) {
print $_;
}
}
This matches now file2.txt which is on a single line but not file1.txt which is on multiple lines. I googled a lot and tried the modifiers /m /s and /g which were suggested but with no luck. Please can you help me to find the right syntax?