home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

3.2.75 index

index 

STR

, 

SUBSTR

, 

POSITION


index 

STR

, 

SUBSTR

This function returns the position of the first occurrence of SUBSTR in STR . The POSITION , if specified, says where to start looking. Positions are based at 0 (or whatever you've set the $[ variable to - but don't do that). If the substring is not found, the function returns one less than the base, ordinarily -1. To work your way through a string, you might say:

$pos = -1;
while (($pos = index($string, $lookfor, $pos)) > -1) {
    print "Found at $pos\n";
    $pos++;
}










??????????????@Mail.ru