Commit | Line | Data |
---|---|---|
8d063cd8 LW |
1 | #!./perl |
2 | ||
3 | # $Header: op.subst,v 1.0 87/12/18 13:14:30 root Exp $ | |
4 | ||
5 | print "1..7\n"; | |
6 | ||
7 | $x = 'foo'; | |
8 | $_ = "x"; | |
9 | s/x/\$x/; | |
10 | print "#1\t:$_: eq :\$x:\n"; | |
11 | if ($_ eq '$x') {print "ok 1\n";} else {print "not ok 1\n";} | |
12 | ||
13 | $_ = "x"; | |
14 | s/x/$x/; | |
15 | print "#2\t:$_: eq :foo:\n"; | |
16 | if ($_ eq 'foo') {print "ok 2\n";} else {print "not ok 2\n";} | |
17 | ||
18 | $_ = "x"; | |
19 | s/x/\$x $x/; | |
20 | print "#3\t:$_: eq :\$x foo:\n"; | |
21 | if ($_ eq '$x foo') {print "ok 3\n";} else {print "not ok 3\n";} | |
22 | ||
23 | $a = 'abcdef'; | |
24 | $b = 'cd'; | |
25 | $a =~ s'(b${b}e)'\n$1'; | |
26 | print "#4\t:$1: eq :bcde:\n"; | |
27 | print "#4\t:$a: eq :a\\n\$1f:\n"; | |
28 | if ($1 eq 'bcde' && $a eq 'a\n$1f') {print "ok 4\n";} else {print "not ok 4\n";} | |
29 | ||
30 | $a = 'abacada'; | |
31 | if (($a =~ s/a/x/g) == 4 && $a eq 'xbxcxdx') | |
32 | {print "ok 5\n";} else {print "not ok 5\n";} | |
33 | ||
34 | if (($a =~ s/a/y/g) == 0 && $a eq 'xbxcxdx') | |
35 | {print "ok 6\n";} else {print "not ok 6\n";} | |
36 | ||
37 | if (($a =~ s/b/y/g) == 1 && $a eq 'xyxcxdx') | |
38 | {print "ok 7\n";} else {print "not ok 7\n";} |