On May 31, Brian Shoemaker said:

>($id,$dir,$code,$etc) = split(/\|/,$i);
>
>However, the Perl 5 book I have lists the syntax of split as.....
>
>lvalue = split(/pattern/,expression,maxSplit);

Perl can automatically add that argument if you have a known number of
elements on the left-hand side:

  # this does NOT produce a list of 10 elements, and take 2 of them
  ($x, $y) = split /:/, "a:b:c:d:e:f:g:h:i:j:k";
  # that gets optimized to
  ($x, $y) = split /:/, "a:b:c:d:e:f:g:h:i:j:k", 3;

So no, you don't need to make any modifications -- Perl does that for you
already.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **

Reply via email to