This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add appropriate skips to t/io/fs.t to fix test failures on Cygwin.
[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 {
3fb41248 47 no warnings 'once';
21735c00
GS
48 print STDOUT "# Calling other\n";
49 local *ARGV;
50 local *ARGVOUT;
51 local $_;
52 @ARGV = mkfiles(5, 4);
53 while (<>) {
54 print STDOUT "# inner \@ARGV: [@ARGV]\n";
55 show();
56 }
57}
58
59sub mkfiles {
3e0057ef 60 my @files = map { "scratch$_" } @_;
21735c00
GS
61 return wantarray ? @files : $files[-1];
62}
63
64END { unlink map { ($_, "$_.bak") } mkfiles(1..5) }