My code tries to extract the range even if the line starts with a * Here is my code:
while (<FILE1>) {
$_ =~ s/^\s+//; #remove leading spaces
$_ =~ s/\s+$//; #remove trailing spaces
if (/IF/ .. /END-IF/) {
if($_ =~ m/END-IF/) {
$flag = 1;
}
print FINAL "$_\n";
if ($flag == 1) {
$flag = 0;
print FINAL "\n\n";
}
}
}
close FINAL;
close FILE1;
My FINAL output file should contain only the the ranges between all IF’s and END-IF’s seperated by \n\n AND if there is an IF within an IF block, The range starting from the first if to the line before the second IF should be saved in FINAL seperated by \n\n
if you want IF and END-IF to be excluded,then use the below:
if you want IF and END-IF to be included,then use the below: