Commit | Line | Data |
---|---|---|
02c45c47 GS |
1 | #!./perl |
2 | ||
55d27857 | 3 | print "1..7\n"; |
02c45c47 GS |
4 | |
5 | $x='banana'; | |
6 | $x=~/.a/g; | |
7 | if (pos($x)==2) {print "ok 1\n"} else {print "not ok 1\n";} | |
8 | ||
9 | $x=~/.z/gc; | |
10 | if (pos($x)==2) {print "ok 2\n"} else {print "not ok 2\n";} | |
11 | ||
12 | sub f { my $p=$_[0]; return $p } | |
13 | ||
14 | $x=~/.a/g; | |
15 | if (f(pos($x))==4) {print "ok 3\n"} else {print "not ok 3\n";} | |
16 | ||
084916e3 JH |
17 | # Is pos() set inside //g? (bug id 19990615.008) |
18 | $x = "test string?"; $x =~ s/\w/pos($x)/eg; | |
19 | print "not " unless $x eq "0123 5678910?"; | |
20 | print "ok 4\n"; | |
21 | ||
55d27857 RG |
22 | # bug ID 20010704.003 |
23 | use Tie::Scalar; | |
24 | tie $y[0], Tie::StdScalar or die $!; | |
25 | $y[0] = "aaa"; | |
26 | $y[0] =~ /./g; | |
27 | if (pos($y[0]) == 1) {print "ok 5\n"} else {print "not ok 5\n"} | |
28 | ||
29 | $x = 0; | |
30 | $y[0] = "aaa"; | |
31 | $y[$x] =~ /./g; | |
32 | if (pos($y[$x]) == 1) {print "ok 6\n"} else {print "not ok 6\n"} | |
33 | untie $y[0]; | |
34 | ||
35 | tie $y{'abc'}, Tie::StdScalar or die $!; | |
36 | $y{'abc'} = "aaa"; | |
37 | $y{'abc'} =~ /./g; | |
38 | if (pos($y{'abc'}) == 1) {print "ok 7\n"} else {print "not ok 7\n"} | |
39 | untie $y{'abc'}; |