Q:

Perl oneliner might be a runaway multi-line ++ message

I am trying to reformat the date for MySQL. This Perl one-liner give me below error message.
I would like understand why it's giving this error message.
echo 'Dec 2 04:08:40 EST 2012' | perl -lane ' my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
                ( $amon, $mday, $hour,$tz, $year) =split('\s+',$_);
                for (my $i = 0; $i < @abbr; $i++) {
                next unless $abbr[$i] =~ /^$amon/;
                $mon=$i;
                }
                $mon++;
                print  "$year-$mon-$mday $hour";

            '

Error Message
syntax error at -e line 3, near ") {"
  (Might be a runaway multi-line ++ string starting on line 2)
syntax error at -e line 9, near ";}"
Execution of -e aborted due to compilation errors.

A:

The problem is that you have tried to embed single quotes within a single-quoted string. You could escape them, but split will split $_ on whitespace by default.
Here is a solution, but as Mat says this is a program, not a one-liner. Put it in a file.
echo 'Dec 2 04:08:40 EST 2012' | perl -lane '
@abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
($amon, $mday, $hour, $tz, $year) = split;
for my $i (0..$#abbr) {
  next unless $abbr[$i] =~ /^$amon/;
  $mon=$i;
}
$mon++;
print  "$year-$mon-$mday $hour";'

