14 my $devnull = File::Spec->devnull;
16 open(TRY, '>Io_argv1.tmp') || (die "Can't open temp file: $!");
18 close TRY or die "Could not close: $!";
21 prog => 'while (<>) { print $., $_; }',
22 args => [ 'Io_argv1.tmp', 'Io_argv1.tmp' ],
24 is($x, "1a line\n2a line\n", '<> from two files');
28 prog => 'while (<>) { print $_; }',
30 args => [ 'Io_argv1.tmp', '-' ],
32 is($x, "a line\nfoo\n", ' from a file and STDIN');
35 prog => 'while (<>) { print $_; }',
38 is($x, "foo\n", ' from just STDIN');
41 @ARGV = ('Io_argv1.tmp', 'Io_argv1.tmp', $devnull, 'Io_argv1.tmp');
45 is($., 3, '$. counts <>');
49 is($y, "1a line\n2a line\n3a line\n", '<> from @ARGV');
52 open(TRY, '>Io_argv1.tmp') or die "Can't open temp file: $!";
53 close TRY or die "Could not close: $!";
54 open(TRY, '>Io_argv2.tmp') or die "Can't open temp file: $!";
55 close TRY or die "Could not close: $!";
56 @ARGV = ('Io_argv1.tmp', 'Io_argv2.tmp');
57 $^I = '_bak'; # not .bak which confuses VMS
66 open(TRY, '<Io_argv1.tmp') or die "Can't open temp file: $!";
68 open(TRY, '<Io_argv2.tmp') or die "Can't open temp file: $!";
70 close TRY or die "Could not close: $!";
75 ok( eof NEVEROPENED, 'eof() true on unopened filehandle' );
77 open STDIN, 'Io_argv1.tmp' or die $!;
79 ok( !eof(), 'STDIN has something' );
83 open STDIN, $devnull or die $!;
85 ok( eof(), 'eof() true with empty @ARGV' );
87 @ARGV = ('Io_argv1.tmp');
90 @ARGV = ($devnull, $devnull);
94 ok( eof(), 'eof() true after closing ARGV' );
98 open F, 'Io_argv1.tmp' or die "Could not open Io_argv1.tmp: $!";
102 open F, $devnull or die;
108 open F, $devnull or die; # restart cycle again
111 close F or die "Could not close: $!";
114 # This used to dump core
115 fresh_perl_is( <<'**PROG**', "foobar", {}, "ARGV aliasing and eof()" );
116 open OUT, ">Io_argv3.tmp" or die "Can't open temp file: $!";
119 open IN, "Io_argv3.tmp" or die "Can't open temp file: $!";
123 print "bar" if eof();
126 unlink "Io_argv3.tmp";
130 unlink 'Io_argv1.tmp', 'Io_argv1.tmp_bak',
131 'Io_argv2.tmp', 'Io_argv2.tmp_bak', 'Io_argv3.tmp';