Commit | Line | Data |
fe14fcc3 |
1 | #!./perl |
99ec4a7e |
2 | use strict; |
3 | require './test.pl'; |
8d063cd8 |
4 | |
103a9d15 |
5 | $^I = $^O eq 'VMS' ? '_bak' : '.bak'; |
fe14fcc3 |
6 | |
99ec4a7e |
7 | plan( tests => 2 ); |
8d063cd8 |
8 | |
62a28c97 |
9 | my @tfiles = (tempfile(), tempfile(), tempfile()); |
10 | my @tfiles_bak = map "$_$^I", @tfiles; |
99ec4a7e |
11 | |
62a28c97 |
12 | END { unlink_all(@tfiles_bak); } |
99ec4a7e |
13 | |
14 | for my $file (@tfiles) { |
15 | runperl( prog => 'print qq(foo\n);', |
16 | args => ['>', $file] ); |
68dc0745 |
17 | } |
99ec4a7e |
18 | |
19 | @ARGV = @tfiles; |
20 | |
8d063cd8 |
21 | while (<>) { |
22 | s/foo/bar/; |
23 | } |
24 | continue { |
25 | print; |
26 | } |
27 | |
99ec4a7e |
28 | is ( runperl( prog => 'print<>;', args => \@tfiles ), |
29 | "bar\nbar\nbar\n", |
30 | "file contents properly replaced" ); |
31 | |
32 | is ( runperl( prog => 'print<>;', args => \@tfiles_bak ), |
33 | "foo\nfoo\nfoo\n", |
34 | "backup file contents stay the same" ); |
8d063cd8 |
35 | |