Skip to content

Instantly share code, notes, and snippets.

@ranguard
Created June 19, 2012 12:51
Show Gist options
  • Select an option

  • Save ranguard/2953985 to your computer and use it in GitHub Desktop.

Select an option

Save ranguard/2953985 to your computer and use it in GitHub Desktop.
issue with split documentation
Anša Vernerová
Hello,
I would like to report that the current documentation for the split command is erronerrous.
http://perldoc.perl.org/functions/split.html says:
--
In time-critical applications, it is worthwhile to avoid splitting into more fields than necessary. Thus, when assigning to a list, if LIMIT is omitted (or zero), then LIMIT is treated as though it were one larger than the number of variables in the list; for the following, LIMIT is implicitly 4:
($login, $passwd, $remainder) = split(/:/);
--
Calling the third argument $remainer is simply wrong - the remainder is the fourth argument, which is not assigned to anything. This must come from some edit of the older version of the documentation, which can be found e.g. at http://www.tu-chemnitz.de/docs/perldoc-html/functions/split.html :
--
The LIMIT parameter can be used to split a line partially
($login, $passwd, $remainder) = split(/:/, $_, 3);
When assigning to a list, if LIMIT is omitted, or zero, Perl supplies a LIMIT one larger than the number of variables in the list, to avoid unnecessary work. For the list above LIMIT would have been 4 by default. In time critical applications it behooves you not to split into more fields than you really need.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment