Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL index Function
Syntax
index STR, SUBSTR, POSITION
index STR, SUBSTR
|
Definition and Usage
Returns the position of the first occurrence of SUBSTR in STR, starting at the
beginning (starting at zero), or from POSITION if specified.
Return Value
Example
Try out following example:
#!/usr/bin/perl
$string = "That is test";
$index = index ($string, 'is');
print "Position of is in the string $index\n";
It produces following result
Position of is in the string 5
|
|

|
|
|