5 $^I = $^O eq 'VMS' ? '_bak' : '.bak';
9 my @tfiles = (tempfile(), tempfile(), tempfile());
10 my @tfiles_bak = map "$_$^I", @tfiles;
12 END { unlink_all(@tfiles_bak); }
14 for my $file (@tfiles) {
15 runperl( prog => 'print qq(foo\n);',
16 args => ['>', $file] );
28 is ( runperl( prog => 'print<>;', args => \@tfiles ),
30 "file contents properly replaced" );
32 is ( runperl( prog => 'print<>;', args => \@tfiles_bak ),
34 "backup file contents stay the same" );
38 # based on code, dosish and epoc systems can't do no-backup inplace
40 $^O =~ /^(MSWin32|cygwin|uwin|dos|epoc|os2)$/
41 and skip("Can't inplace edit without backups on $^O", 4);
43 our @ifiles = ( tempfile(), tempfile(), tempfile() );
46 for my $file (@ifiles) {
47 runperl( prog => 'print qq(bar\n);',
48 args => [ '>', $file ] );
52 local @ARGV = @ifiles;
58 is(scalar(@ARGV), 0, "consumed ARGV");
60 # runperl may quote its arguments, so don't expect to be able
61 # to reuse things you send it.
63 my @my_ifiles = @ifiles;
64 is( runperl( prog => 'print<>;', args => \@my_ifiles ),
65 "foobar\nfoobar\nfoobar\n",
66 "normal inplace edit");
69 # test * equivalency RT #70802
71 for my $file (@ifiles) {
72 runperl( prog => 'print qq(bar\n);',
73 args => [ '>', $file ] );
77 local @ARGV = @ifiles;
83 is(scalar(@ARGV), 0, "consumed ARGV");
85 my @my_ifiles = @ifiles;
86 is( runperl( prog => 'print<>;', args => \@my_ifiles ),
87 "foobar\nfoobar\nfoobar\n",
88 "normal inplace edit");
91 END { unlink_all(@ifiles); }