What follows is a module I wrote quite some time ago
(as a proof of concept)
that "fixes"
index in a different way.
It returns
undef if there is no match,
and the position of the match otherwise - however, if
it matches at the beginning of the string, "0 but true"
is returned.
package Perl;
use Exporter;
use vars qw /@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS/;
@ISA = qw /Exporter/;
@EXPORT = qw /index/;
@EXPORT_OK = qw //;
%EXPORT_TAGS = ();
sub index {
my $result;
$result = 2 == @_ ? CORE::index ($_ [0], $_ [1])
: CORE::index ($_ [0], $_ [1], $_ [2]);
$result < 0 ? undef : $result || "00";
}
1;
__END__
-- Abigail