in reply to Pattern matching "dirty" data sources
1. You can read the whole file in as one big line and then for a m//mg fo what you are looking for.
{ local $/=""; $file=<INFILE>; } #Now you can regex with m//mg all you want
Those curly brackets in the snippet above are important, they change the scope of the local $/ (the input record separator) so you can clear it just for the duration of the assignment to $file.
Option 2 is slightly different. Since it seems you are counting lines, this one might be better for what you are looking for. After you start reading an SQL line, simply keep reading until you hit the semicolon that concludes that line of code and concatenate everything together.
while(<INFILE>){ chomp(); $line.=" " .$_; #This adds a space between each line if (/\;$/) { #This works as long as the last char on the line is ;, m +ay need to be tweaked. #regexes go here $line=""; }
Cheers
|
|---|