Would something like this suffice? The \m modifier lets the ^ metacharacter match next to a newline in your multiline $line value.
#!/usr/bin/perl
$/ = ";\n";
while (my $line = <DATA> ){
$line =~ s/^#.*[\n\r]*//gm;
print "Query: $line" unless $line=~/^\s+$/;
}
__DATA__
# one comment
# two comment
# another comment
insert into table_name values(1, 'testing 1 2 3');
# more comments
insert into table_name values (2, 'test •')
OUTPUT:
Query: insert into table_name values(1, 'testing 1 2 3');
Query: insert into table_name values (2, 'test •');