6 $^I = $^O eq 'VMS' ? '_bak' : '.bak';
10 my @tfiles = (tempfile(), tempfile(), tempfile());
11 my @tfiles_bak = map "$_$^I", @tfiles;
13 END { unlink_all(@tfiles_bak); }
15 for my $file (@tfiles) {
16 runperl( prog => 'print qq(foo\n);',
17 args => ['>', $file] );
29 is ( runperl( prog => 'print<>;', args => \@tfiles ),
31 "file contents properly replaced" );
33 is ( runperl( prog => 'print<>;', args => \@tfiles_bak ),
35 "backup file contents stay the same" );
39 # based on code, dosish systems can't do no-backup inplace
41 $^O =~ /^(MSWin32|cygwin|uwin|dos|os2)$/
42 and skip("Can't inplace edit without backups on $^O", 4);
44 our @ifiles = ( tempfile(), tempfile(), tempfile() );
47 for my $file (@ifiles) {
48 runperl( prog => 'print qq(bar\n);',
49 args => [ '>', $file ] );
53 local @ARGV = @ifiles;
59 is(scalar(@ARGV), 0, "consumed ARGV");
61 # runperl may quote its arguments, so don't expect to be able
62 # to reuse things you send it.
64 my @my_ifiles = @ifiles;
65 is( runperl( prog => 'print<>;', args => \@my_ifiles ),
66 "foobar\nfoobar\nfoobar\n",
67 "normal inplace edit");
70 # test * equivalence RT #70802
72 for my $file (@ifiles) {
73 runperl( prog => 'print qq(bar\n);',
74 args => [ '>', $file ] );
78 local @ARGV = @ifiles;
84 is(scalar(@ARGV), 0, "consumed ARGV");
86 my @my_ifiles = @ifiles;
87 is( runperl( prog => 'print<>;', args => \@my_ifiles ),
88 "foobar\nfoobar\nfoobar\n",
89 "normal inplace edit");
92 END { unlink_all(@ifiles); }