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

Programming Perl


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++;
}

3.2.74 import Book Index 3.2.76 int

[ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ]







(追記) (追記ここまで)


(追記) (追記ここまで)


AltStyle によって変換されたページ (->オリジナル) /