Well if you just looked at a printout, then this could have been a print out of single scalar text variable containing several lines. To split each line's values into an array, you have to "extract the lines" from the single text variable.
Another fine point once you have extracted the lines...
There are five white space characters, space,\t,\f,\n,\r.
There are 2 ways to split on any of these white space characters.
Perl has a special case, ' 'for the split. This is the same as the
regex /\s+/ which splits on any of the five characters
except in how it handles the first potentially "blank" field.
Demo Code:
#!/usr/bin/perl
use strict;
use warnings;
my @lines = ("a b c\n", " a b c\n");
foreach my $line (@lines)
{
my @array = split ' ',$line;
print join ("|",@array), "\n";
}
foreach my $line (@lines)
{
my @array = split /\s+/,$line;
print join ("|",@array), "\n";
}
__END__
#using split on ' '
a|b|c
a|b|c
# using split on /\s+/ (the default)
a|b|c
|a|b|c
|