3 # $Header: op.index,v 3.0 89/10/18 15:29:29 lwall Locked $
8 $foo = 'Now is the time for all good men to come to the aid of their country.';
10 $first = substr($foo,0,index($foo,'the'));
11 print ($first eq "Now is " ? "ok 1\n" : "not ok 1\n");
13 $last = substr($foo,rindex($foo,'the'),100);
14 print ($last eq "their country." ? "ok 2\n" : "not ok 2\n");
16 $last = substr($foo,index($foo,'Now'),2);
17 print ($last eq "No" ? "ok 3\n" : "not ok 3\n");
19 $last = substr($foo,rindex($foo,'Now'),2);
20 print ($last eq "No" ? "ok 4\n" : "not ok 4\n");
22 $last = substr($foo,index($foo,'.'),100);
23 print ($last eq "." ? "ok 5\n" : "not ok 5\n");
25 $last = substr($foo,rindex($foo,'.'),100);
26 print ($last eq "." ? "ok 6\n" : "not ok 6\n");