Strings In Depth5 / 18
Up next

Find with index

use strict;
use warnings;
use feature 'say';

my $s = "abcabc";
# index finds the first position, -1 if absent
say index($s, "b");
say index($s, "b", 2);
# rindex searches from the right
say rindex($s, "a");
What you're solving

index and rindex locate a substring