🎴 Flashcard Mode

Perl Programming Fundamentals

Card1 / 20
Mastered0
Review0
QuestionClick to flip

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

AnswerClick to flip back
A
6
💡 Explanation:

index($string, "cd", 3) searches for cd starting from position 3 in abcdabcd. Positions 0-7: abcdabcd. From index 3, the next cd starts at index 6 (second cd). index returns the position where substring is found, making option A correct. Starting position 3 means it skips the first cd at position 2.

Change Mode