Multiple choice technology programming languages

Which Perl function can be used to identify the first found occurrence of a substring?

  1. find

  2. index

  3. locate

  4. allocate

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

Perl's index() function finds the first occurrence of a substring, returning the position or -1 if not found. This is the standard Perl function for substring search, making option B correct. Functions like find, locate, and allocate don't exist in Perl for this purpose - rindex() searches from the end, not first occurrence.