1N/A#!./perl
1N/A
1N/Aprint "1..5\n";
1N/A
1N/Amy $j = 1;
1N/Afor $i ( 1,2,5,4,3 ) {
1N/A $file = mkfiles($i);
1N/A open(FH, "> $file") || die "can't create $file: $!";
1N/A print FH "not ok " . $j++ . "\n";
1N/A close(FH) || die "Can't close $file: $!";
1N/A}
1N/A
1N/A
1N/A{
1N/A local *ARGV;
1N/A local $^I = '.bak';
1N/A local $_;
1N/A @ARGV = mkfiles(1..3);
1N/A $n = 0;
1N/A while (<>) {
1N/A print STDOUT "# initial \@ARGV: [@ARGV]\n";
1N/A if ($n++ == 2) {
1N/A other();
1N/A }
1N/A show();
1N/A }
1N/A}
1N/A
1N/A$^I = undef;
1N/A@ARGV = mkfiles(1..3);
1N/A$n = 0;
1N/Awhile (<>) {
1N/A print STDOUT "#final \@ARGV: [@ARGV]\n";
1N/A if ($n++ == 2) {
1N/A other();
1N/A }
1N/A show();
1N/A}
1N/A
1N/Asub show {
1N/A #warn "$ARGV: $_";
1N/A s/^not //;
1N/A print;
1N/A}
1N/A
1N/Asub other {
1N/A print STDOUT "# Calling other\n";
1N/A local *ARGV;
1N/A local *ARGVOUT;
1N/A local $_;
1N/A @ARGV = mkfiles(5, 4);
1N/A while (<>) {
1N/A print STDOUT "# inner \@ARGV: [@ARGV]\n";
1N/A show();
1N/A }
1N/A}
1N/A
1N/Asub mkfiles {
1N/A my @files = map { "scratch$_" } @_;
1N/A return wantarray ? @files : $files[-1];
1N/A}
1N/A
1N/AEND { unlink map { ($_, "$_.bak") } mkfiles(1..5) }