| perl6 Built-ins: Merge and generalize index and rindex |
Built-ins: Merge and generalize index and rindex
Maintainer: Damian Conway <damian@conway.org> Date: 7 Aug 2000 Mailing List: perl6-language@perl.org Number: 53 Version: 10 Status: Developing
This RFC proposes that the index and rindex functions be merged and generalized, by adding a fourth parameter to index.
At present index only returns the index of the first occurrence of a specified substring. It is proposed that index take a fourth parameter telling it which occurrence of a specified substring to locate:
$first = index $string, $substring, 0, 1; # first occurrence
$first = index $string, $substring, 0, 2; # second occurrence
$first = index $string, $substring, 0, 3; # third occurrence
If omitted, this fourth parameter would default to 1, thus preversing the current behaviour.
The rindex function would be unnecessary, being replaced by:
$last = index $string, $substring, -1, -1; # last occurence
Dammit, Jim, I'm a doctor, not an engineer!
|
Perl.org sites
: bugs
| dev
| history
| jobs
| learn
| lists
| use
Site Information and Contacts |
|