Christopher Spears wrote:
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.
C:\>perldoc -f split
split /PATTERN/,EXPR,LIMIT
2 is the LIMIT. It makes sure that $line wont be sliced in more then two
parts. If LIMIT is omitted, $line get splited on every /PATTERN/ occurrence.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>