my $split = Data::Record->new( { split => $comment, unless => $RE{quoted}, chomp => 0, trim => 1, } ); my @chunks = $split->records($line_of_sql); if ( @chunks > 1 ) { assert( $chunks[-2] =~ /$some_text/ ); $chunks[-2] =~ s/$some_text//; # XXX remove comment indicator pop @chunks; # XXX remove comment }