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