9 my($prog, $stdin, @files) = @_;
12 if ($^O eq 'MSWin32' || $^O eq 'NetWare' || $^O eq 'VMS' ) {
13 $cmd = qq{$^X -e "$prog"};
14 $cmd .= " ". join ' ', map qq{"$_"}, @files if @files;
15 $cmd = qq{$^X -le "print '$stdin'" | } . $cmd if defined $stdin;
18 $cmd = qq{$^X -e '$prog' @files};
19 $cmd = qq{$^X -le 'print q{$stdin}' | } . $cmd if defined $stdin;
22 # The combination of $^X, pipes and STDIN is broken on VMS and
24 if( defined $stdin && $^O eq 'VMS' && $TODO ) {
29 $result =~ s/\n\n/\n/ if $^O eq 'VMS'; # pipes sometimes double these
40 my $devnull = File::Spec->devnull;
42 open(TRY, '>Io_argv1.tmp') || (die "Can't open temp file: $!");
46 $x = runthis( 'while (<>) { print $., $_; }', undef, ('Io_argv1.tmp') x 2);
47 is($x, "1a line\n2a line\n", '<> from two files');
50 local $TODO = 'The combo of STDIN, pipes and $^X is broken on VMS'
52 $x = runthis( 'while (<>) { print $_; }', 'foo', 'Io_argv1.tmp', '-' );
53 is($x, "a line\nfoo\n", ' from a file and STDIN');
55 $x = runthis( 'while (<>) {print $_;}', 'foo' );
56 is($x, "foo\n", ' from just STDIN');
59 @ARGV = ('Io_argv1.tmp', 'Io_argv1.tmp', $devnull, 'Io_argv1.tmp');
63 is($., 3, '$. counts <>');
67 is($y, "1a line\n2a line\n3a line\n", '<> from @ARGV');
70 open(TRY, '>Io_argv1.tmp') or die "Can't open temp file: $!";
72 open(TRY, '>Io_argv2.tmp') or die "Can't open temp file: $!";
74 @ARGV = ('Io_argv1.tmp', 'Io_argv2.tmp');
75 $^I = '_bak'; # not .bak which confuses VMS
84 open(TRY, '<Io_argv1.tmp') or die "Can't open temp file: $!";
86 open(TRY, '<Io_argv2.tmp') or die "Can't open temp file: $!";
93 ok( eof NEVEROPENED, 'eof() true on unopened filehandle' );
95 open STDIN, 'Io_argv1.tmp' or die $!;
97 ok( !eof(), 'STDIN has something' );
101 open STDIN, $devnull or die $!;
103 ok( eof(), 'eof() true with empty @ARGV' );
105 @ARGV = ('Io_argv1.tmp');
108 @ARGV = ($devnull, $devnull);
111 close ARGV or die $!;
112 ok( eof(), 'eof() true after closing ARGV' );
116 open F, 'Io_argv1.tmp' or die;
120 open F, $devnull or die;
126 open F, $devnull or die; # restart cycle again
132 END { unlink 'Io_argv1.tmp', 'Io_argv1.tmp_bak', 'Io_argv2.tmp', 'Io_argv2.tmp_bak' }