xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/io/iprefix.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gate$^I = 'bak*';
4*0Sstevel@tonic-gate
5*0Sstevel@tonic-gate# Modified from the original inplace.t to test adding prefixes
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gateprint "1..2\n";
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate@ARGV = ('.a','.b','.c');
10*0Sstevel@tonic-gateif ($^O eq 'MSWin32') {
11*0Sstevel@tonic-gate  $CAT = '.\perl -e "print<>"';
12*0Sstevel@tonic-gate  `.\\perl -le "print 'foo'" > .a`;
13*0Sstevel@tonic-gate  `.\\perl -le "print 'foo'" > .b`;
14*0Sstevel@tonic-gate  `.\\perl -le "print 'foo'" > .c`;
15*0Sstevel@tonic-gate}
16*0Sstevel@tonic-gateelsif ($^O eq 'NetWare') {
17*0Sstevel@tonic-gate  $CAT = 'perl -e "print<>"';
18*0Sstevel@tonic-gate  `perl -le "print 'foo'" > .a`;
19*0Sstevel@tonic-gate  `perl -le "print 'foo'" > .b`;
20*0Sstevel@tonic-gate  `perl -le "print 'foo'" > .c`;
21*0Sstevel@tonic-gate}
22*0Sstevel@tonic-gateelsif ($^O eq 'VMS') {
23*0Sstevel@tonic-gate  $CAT = 'MCR []perl. -e "print<>"';
24*0Sstevel@tonic-gate  `MCR []perl. -le "print 'foo'" > ./.a`;
25*0Sstevel@tonic-gate  `MCR []perl. -le "print 'foo'" > ./.b`;
26*0Sstevel@tonic-gate  `MCR []perl. -le "print 'foo'" > ./.c`;
27*0Sstevel@tonic-gate}
28*0Sstevel@tonic-gateelsif ($^O eq 'MacOS') {
29*0Sstevel@tonic-gate  $CAT = "$^X -e \"print<>\"";
30*0Sstevel@tonic-gate  `$^X -le "print 'foo'" > .a`;
31*0Sstevel@tonic-gate  `$^X -le "print 'foo'" > .b`;
32*0Sstevel@tonic-gate  `$^X -le "print 'foo'" > .c`;
33*0Sstevel@tonic-gate}
34*0Sstevel@tonic-gateelse {
35*0Sstevel@tonic-gate  $CAT = 'cat';
36*0Sstevel@tonic-gate  `echo foo | tee .a .b .c`;
37*0Sstevel@tonic-gate}
38*0Sstevel@tonic-gatewhile (<>) {
39*0Sstevel@tonic-gate    s/foo/bar/;
40*0Sstevel@tonic-gate}
41*0Sstevel@tonic-gatecontinue {
42*0Sstevel@tonic-gate    print;
43*0Sstevel@tonic-gate}
44*0Sstevel@tonic-gate
45*0Sstevel@tonic-gateif (`$CAT .a .b .c` eq "bar\nbar\nbar\n") {print "ok 1\n";} else {print "not ok 1\n";}
46*0Sstevel@tonic-gateif (`$CAT bak.a bak.b bak.c` eq "foo\nfoo\nfoo\n") {print "ok 2\n";} else {print "not ok 2\n";}
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gateunlink '.a', '.b', '.c', 'bak.a', 'bak.b', 'bak.c';
49