This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta - move split change to other perlfunc changes and add issue link
[perl5.git] / t / io / iprefix.t
CommitLineData
2d259d92 1#!./perl
99ec4a7e 2use strict;
b5efbd1f 3chdir 't' if -d 't';
99ec4a7e 4require './test.pl';
2d259d92 5
62a28c97 6$^I = 'bak.*';
2d259d92
CK
7
8# Modified from the original inplace.t to test adding prefixes
9
99ec4a7e 10plan( tests => 2 );
2d259d92 11
62a28c97
NC
12my @tfiles = (tempfile(), tempfile(), tempfile());
13my @tfiles_bak = map "bak.$_", @tfiles;
99ec4a7e 14
62a28c97 15END { unlink_all(@tfiles_bak); }
99ec4a7e
CB
16
17for my $file (@tfiles) {
18 runperl( prog => 'print qq(foo\n);',
19 args => ['>', $file] );
2d259d92 20}
99ec4a7e
CB
21
22@ARGV = @tfiles;
23
2d259d92
CK
24while (<>) {
25 s/foo/bar/;
26}
27continue {
28 print;
29}
30
99ec4a7e
CB
31is ( runperl( prog => 'print<>;', args => \@tfiles ),
32 "bar\nbar\nbar\n",
33 "file contents properly replaced" );
34
35is ( runperl( prog => 'print<>;', args => \@tfiles_bak ),
36 "foo\nfoo\nfoo\n",
37 "backup file contents stay the same" );
2d259d92 38