This reply wasn't addressed to me, but here is an explanation for you:
undef as an lvalue is one way of
"throwing away" a value from the right hand side
of the "=". This is actually very similar to
the way that 'C' does it with an input format
statement.
my @a = (1,2,3,4,5);
(undef, my @b) = (@a);
print "@b\n";
#prints: 2 3 4 5 (the 1 is gone)
Perl has another way, a "list slice" and I prefer this in
my Perl code to the 'C' way. For example to "get rid" of
the "2":
my @a = (1,2,3,4,5);
my @b = @a[0,2..4];
print "@b\n";
#prints: 1 3 4 5
As far as the third parameter to split being -1, I see no reason for this
at all as this means "no limit", the default. There are reasons to "limit" the
number of things returned from split(), but I don't see it here.
my $text = "1 2 3 4 5 6";
my @tokens = split(/\s+/,$text,2);
foreach (@tokens)
{
print "$_\n";
}
#prints:
1
2 3 4 5 6
The above code limits the split to 2 things.
|