This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 1.0 patch 14: a2p incorrectly translates 'for (a in b)' construct.
[perl5.git] / t / op.subst
CommitLineData
8d063cd8
LW
1#!./perl
2
3# $Header: op.subst,v 1.0 87/12/18 13:14:30 root Exp $
4
5print "1..7\n";
6
7$x = 'foo';
8$_ = "x";
9s/x/\$x/;
10print "#1\t:$_: eq :\$x:\n";
11if ($_ eq '$x') {print "ok 1\n";} else {print "not ok 1\n";}
12
13$_ = "x";
14s/x/$x/;
15print "#2\t:$_: eq :foo:\n";
16if ($_ eq 'foo') {print "ok 2\n";} else {print "not ok 2\n";}
17
18$_ = "x";
19s/x/\$x $x/;
20print "#3\t:$_: eq :\$x foo:\n";
21if ($_ 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';
26print "#4\t:$1: eq :bcde:\n";
27print "#4\t:$a: eq :a\\n\$1f:\n";
28if ($1 eq 'bcde' && $a eq 'a\n$1f') {print "ok 4\n";} else {print "not ok 4\n";}
29
30$a = 'abacada';
31if (($a =~ s/a/x/g) == 4 && $a eq 'xbxcxdx')
32 {print "ok 5\n";} else {print "not ok 5\n";}
33
34if (($a =~ s/a/y/g) == 0 && $a eq 'xbxcxdx')
35 {print "ok 6\n";} else {print "not ok 6\n";}
36
37if (($a =~ s/b/y/g) == 1 && $a eq 'xyxcxdx')
38 {print "ok 7\n";} else {print "not ok 7\n";}