This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate mainline
[perl5.git] / t / io / nargv.t
CommitLineData
21735c00
GS
1#!./perl
2
3print "1..5\n";
4
5my $j = 1;
6for $i ( 1,2,5,4,3 ) {
7 $file = mkfiles($i);
8 open(FH, "> $file") || die "can't create $file: $!";
9 print FH "not ok " . $j++ . "\n";
10 close(FH) || die "Can't close $file: $!";
11}
12
13
14{
15 local *ARGV;
16 local $^I = '.bak';
17 local $_;
18 @ARGV = mkfiles(1..3);
19 $n = 0;
20 while (<>) {
21 print STDOUT "# initial \@ARGV: [@ARGV]\n";
22 if ($n++ == 2) {
23 other();
24 }
25 show();
26 }
27}
28
29$^I = undef;
30@ARGV = mkfiles(1..3);
31$n = 0;
32while (<>) {
33 print STDOUT "#final \@ARGV: [@ARGV]\n";
34 if ($n++ == 2) {
35 other();
36 }
37 show();
38}
39
40sub show {
41 #warn "$ARGV: $_";
42 s/^not //;
43 print;
44}
45
46sub other {
47 print STDOUT "# Calling other\n";
48 local *ARGV;
49 local *ARGVOUT;
50 local $_;
51 @ARGV = mkfiles(5, 4);
52 while (<>) {
53 print STDOUT "# inner \@ARGV: [@ARGV]\n";
54 show();
55 }
56}
57
58sub mkfiles {
3e0057ef 59 my @files = map { "scratch$_" } @_;
21735c00
GS
60 return wantarray ? @files : $files[-1];
61}
62
63END { unlink map { ($_, "$_.bak") } mkfiles(1..5) }