added patch for -i'foo*bar', made code somewhat simpler, tweaked doc
[p5sagit/p5-mst-13.2.git] / t / io / iprefix.t
1 #!./perl
2
3 $^I = 'bak*';
4
5 # Modified from the original inplace.t to test adding prefixes
6
7 print "1..2\n";
8
9 @ARGV = ('.a','.b','.c');
10 if ($^O eq 'MSWin32') {
11   $CAT = '.\perl -e "print<>"';
12   `.\\perl -le "print 'foo'" > .a`;
13   `.\\perl -le "print 'foo'" > .b`;
14   `.\\perl -le "print 'foo'" > .c`;
15 }
16 else {
17   $CAT = 'cat';
18   `echo foo | tee .a .b .c`;
19 }
20 while (<>) {
21     s/foo/bar/;
22 }
23 continue {
24     print;
25 }
26
27 if (`$CAT .a .b .c` eq "bar\nbar\nbar\n") {print "ok 1\n";} else {print "not ok 1\n";}
28 if (`$CAT bak.a bak.b bak.c` eq "foo\nfoo\nfoo\n") {print "ok 2\n";} else {print "not ok 2\n";}
29
30 unlink '.a', '.b', '.c', 'bak.a', 'bak.b', 'bak.c';