Because the entire line got stocked in the $cycle_code variable. The other two variables are empty strings.
Konerak
2010-05-06 09:28:04
Because the entire line got stocked in the $cycle_code variable. The other two variables are empty strings.
You should add the following line to the top of your code:
use warnings;
Or, if your already have it there, you should pay attention to the warning messages you receive. Others have correctly pointed out that your input line does not have any literal pipes. I think you really want something like this:
use strict;
use warnings;
my @tmp_field_validation = (" 1 10 2009\n");
foreach my $line (@tmp_field_validation)
{
chomp $line;
$line =~ s/^\s*//;
my ($cycle_code,$cycle_month,$cycle_year)= split /\s+/, $line;
print "$line\n";
print "$cycle_code|$cycle_month|$cycle_year";
}
Outputs the following:
1 10 2009
1|10|2009