6 $Is_VMS = $^O eq 'VMS';
12 sub ok { print "ok $test\n"; $test++ }
18 unlink("afile") if -f "afile";
19 print "$!\nnot " unless open(my $f,"+>afile");
22 print "not " unless -f "afile";
24 print "not " unless print $f "SomeData\n";
26 print "not " unless tell($f) == 9;
28 print "not " unless seek($f,0,0);
31 print "not " unless $b eq "SomeData\n";
33 print "not " unless -f $f;
35 eval { die "Message" };
37 print "not " unless $@ =~ /<\$f> line 1/;
39 print "not " unless close($f);
46 print "# \$!='$!'\nnot " unless open(my $f,'>', 'afile');
49 print "not " unless close($f);
51 print "not " unless -s 'afile' < 10;
57 print "# \$!='$!'\nnot " unless open(my $f,'>>', 'afile');
60 print "not " unless close($f);
62 print "not " unless -s 'afile' > 10;
68 print "# \$!='$!'\nnot " unless open(my $f, '<', 'afile');
71 print "not " unless @rows == 2;
73 print "not " unless close($f);
79 print "not " unless -s 'afile' < 20;
81 print "# \$!='$!'\nnot " unless open(my $f, '+<', 'afile');
84 print "not " unless @rows == 2;
87 print $f "yet another row\n";
88 print "not " unless close($f);
90 print "not " unless -s 'afile' > 20;
98 for (24..26) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
101 print "# \$!='$!'\nnot " unless open(my $f, '-|', <<'EOC');
102 ./perl -e "print qq(a row\n); print qq(another row\n)"
106 print "not " unless @rows == 2;
108 print "not " unless close($f);
114 for (27..30) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
117 print "# \$!='$!'\nnot " unless open(my $f, '|-', <<'EOC');
118 ./perl -pe "s/^not //"
122 print $f "not ok $test\n"; $test++;
123 print $f "not ok $test\n"; $test++;
124 print "#\nnot " unless close($f);
130 eval <<'EOE' and print "not ";
131 open my $f, '<&', 'afile';
135 $@ =~ /Unknown open\(\) mode \'<&\'/ or print "not ";
142 unlink("afile") if -f "afile";
143 print "$!\nnot " unless open(local $f,"+>afile");
146 print "not " unless -f "afile";
148 print "not " unless print $f "SomeData\n";
150 print "not " unless tell($f) == 9;
152 print "not " unless seek($f,0,0);
155 print "not " unless $b eq "SomeData\n";
157 print "not " unless -f $f;
159 eval { die "Message" };
161 print "not " unless $@ =~ /<\$f> line 1/;
163 print "not " unless close($f);
170 print "# \$!='$!'\nnot " unless open(local $f,'>', 'afile');
173 print "not " unless close($f);
175 print "not " unless -s 'afile' < 10;
181 print "# \$!='$!'\nnot " unless open(local $f,'>>', 'afile');
184 print "not " unless close($f);
186 print "not " unless -s 'afile' > 10;
192 print "# \$!='$!'\nnot " unless open(local $f, '<', 'afile');
195 print "not " unless @rows == 2;
197 print "not " unless close($f);
203 print "not " unless -s 'afile' < 20;
205 print "# \$!='$!'\nnot " unless open(local $f, '+<', 'afile');
208 print "not " unless @rows == 2;
211 print $f "yet another row\n";
212 print "not " unless close($f);
214 print "not " unless -s 'afile' > 20;
222 for (56..58) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
225 print "# \$!='$!'\nnot " unless open(local $f, '-|', <<'EOC');
226 ./perl -e "print qq(a row\n); print qq(another row\n)"
230 print "not " unless @rows == 2;
232 print "not " unless close($f);
238 for (59..62) { print "ok $_ # skipped: not Unix fork\n"; $test++;}
241 print "# \$!='$!'\nnot " unless open(local $f, '|-', <<'EOC');
242 ./perl -pe "s/^not //"
246 print $f "not ok $test\n"; $test++;
247 print $f "not ok $test\n"; $test++;
248 print "#\nnot " unless close($f);
254 eval <<'EOE' and print "not ";
255 open local $f, '<&', 'afile';
259 $@ =~ /Unknown open\(\) mode \'<&\'/ or print "not ";
266 open(F, "echo #foo|") or print "not ";
272 open(F, "-|", "echo #foo") or print "not ";