use strict;
use Data::Dumper;
open (FILE, 'input.txt');
my @wanted = ();
my $in_section = 0;
my $line = '';
while (<FILE>) {
chomp;
if (/^\s*SQL\d{4}[A-Z].*/i) {
$line .= "$_\n";
$in_section = 1;
next;
}
if (/^\s*$/ and $in_section) {
$in_section = 0;
push @wanted, $line;
$line = '';
}
$line .= "$_\n" if ($in_section);
}
close FILE;
print Dumper(\@wanted);