Hi.
From documentation:
perldoc -f split
split /PATTERN/,EXPR,LIMIT
If LIMIT is specified and positive, splits into no more than that many
fields (though it may split into
fewer). If LIMIT is unspecified or zero, trailing null fields are stripped.
If LIMIT is negative, it is treated as if an arbitrarily large LIMIT had
been specified.
Eg:
The LIMIT parameter can be used to split a line partially
($login, $passwd, $remainder) = split(/:/, $_, 3); # --> Implies not
more than 3 fields.
-Prasanna
Christopher Spears wrote:
I've been learning about data structures by reading
the Programming Perl book. Here is a code snippet:
while ($line = <>) {
($who, $rest) = split /:\s*/, $line, 2;
@fields = split ' ', $rest;
$HoA{$who} = [ @fields ];
}
The part that confuses me is:
($who, $rest) = split /:\s*/, $line, 2;
I understand that it takes the input and splits it
into two parts along the regular expression, but I
can't figure out what the 2 means.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>