#!/usr/bin/perl
$big = "hello world";
$small = "wor";
$where = index($big, $small);
print "we got at $where\n";
./index.pl
we got at 6
#!/usr/bin/perl
my $big = "how world windows";
my $where = index($big, "w");
print "we got at $where\n";
my $where1 = index($big, "w", $where + 1);
print "we got at $where1\n";
my $where2 = index($big, "w", $where1 + 1);
print "we got at $where2\n";
./index.pl
we got at 2
we got at 4
we got at 10
#!/usr/bin/perl
my $path = "/home/beyes/perl/";
my $position = rindex($path, "/");
print "$position\n";
./rindex.pl
6
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |