$INDEX = index($STRING, $SUBSTRING);Perl's index() function takes a string and a substring (another string). It will return the position value of the first occurance of the substring within the string.
This is similar to a regular expression call, but without all the overhead of the regex search patterns. It simply returns the index value of the substring if it exists within the string.
$index = index('barfoobar', 'foo');This will print 3, which is the index value of the start of the substring foo. Note that you can also use it to determine whether or not a string is simply present within another string. If it isn't, the index function will return a value of -1 like so:
print $index . "\n";
$index = index('barfoobar', 'bob');
print $index . "\n";
