in reply to Regex to end of a line from previous line

Try something like this:
while (my $line = <FILE>) { if($line =~ /SQL/) { chomp($date = `date`); chomp ($errcode = $line); print ERR "$date - $errcode\n"; }#end of if }#end of while

P.S. good indenting makes the # end of $something comments superfluous, and increases readability.

Perl 6 - links to (nearly) everything that is Perl 6.