Commit | Line | Data |
---|---|---|
2d259d92 | 1 | #!./perl |
99ec4a7e CB |
2 | use strict; |
3 | require './test.pl'; | |
2d259d92 | 4 | |
62a28c97 | 5 | $^I = 'bak.*'; |
2d259d92 CK |
6 | |
7 | # Modified from the original inplace.t to test adding prefixes | |
8 | ||
99ec4a7e | 9 | plan( tests => 2 ); |
2d259d92 | 10 | |
62a28c97 NC |
11 | my @tfiles = (tempfile(), tempfile(), tempfile()); |
12 | my @tfiles_bak = map "bak.$_", @tfiles; | |
99ec4a7e | 13 | |
62a28c97 | 14 | END { unlink_all(@tfiles_bak); } |
99ec4a7e CB |
15 | |
16 | for my $file (@tfiles) { | |
17 | runperl( prog => 'print qq(foo\n);', | |
18 | args => ['>', $file] ); | |
2d259d92 | 19 | } |
99ec4a7e CB |
20 | |
21 | @ARGV = @tfiles; | |
22 | ||
2d259d92 CK |
23 | while (<>) { |
24 | s/foo/bar/; | |
25 | } | |
26 | continue { | |
27 | print; | |
28 | } | |
29 | ||
99ec4a7e CB |
30 | is ( runperl( prog => 'print<>;', args => \@tfiles ), |
31 | "bar\nbar\nbar\n", | |
32 | "file contents properly replaced" ); | |
33 | ||
34 | is ( runperl( prog => 'print<>;', args => \@tfiles_bak ), | |
35 | "foo\nfoo\nfoo\n", | |
36 | "backup file contents stay the same" ); | |
2d259d92 | 37 |