Why do I get strange output from Perl using SQL?

Posted by benjamin button on Stack Overflow See other posts from Stack Overflow or by benjamin button
Published on 2010-05-06T09:22:25Z Indexed on 2010/05/06 23:58 UTC
Read the original article Hit count: 216

Filed under:
|

Here is my Perl code:

foreach my $line  (@tmp_field_validation)
{
        chomp $line;
        my ($cycle_code,$cycle_month,$cycle_year)= split /\s*\|\s*/, $line;
        $cycle_code=~ s/^\s*(.*)\s*$/$1/;
        $cycle_month=~ s/^\s*(.*)\s*$/$1/;
        $cycle_year=~ s/^\s*(.*)\s*$/$1/;
        print "$line\n";
        print "$cycle_code|$cycle_month|$cycle_year";
}

Here is the output:

         1          10       2009
1           10       2009||

What's wrong over here? I expected the pipes to be between the variables. Why are the pipes getting printed after all the three variables?

© Stack Overflow or respective owner

Related posts about perl

Related posts about unix