Multiple choice technology programming languages

If \$string contains abcdabcd , what will the following call return? index (\$string, “cd”, 3);

  1. 6

  2. 4

  3. -1

  4. 3

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The Perl index function searches for a substring starting at a specified offset. For index($string, "cd", 3), it searches for "cd" in "abcdabcd" starting at index 3. The first occurrence of "cd" starts at index 2, and the second starts at index 6.