summaryrefslogtreecommitdiff
path: root/t/io/dup.t
blob: a641db752a4dc095d808693cf58b41daddd03d18 (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
#!./perl

# $RCSfile: dup.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:27 $

print "1..8\n";

print "ok 1\n";

open(dupout,">&STDOUT");
open(duperr,">&STDERR");

open(STDOUT,">Io.dup") || die "Can't open stdout";
open(STDERR,">&STDOUT") || die "Can't open stderr";

select(STDERR); $| = 1;
select(STDOUT); $| = 1;

print STDOUT "ok 2\n";
print STDERR "ok 3\n";
    print `echo ok 4`;
    print `echo ok 5 1>&2`; # does this work?
    system 'echo ok 6';
    system 'echo ok 7 1>&2';

close(STDOUT);
close(STDERR);

open(STDOUT,">&dupout");
open(STDERR,">&duperr");

if (($^O eq 'MSWin32') || ($^O eq 'NetWare')) { print `type Io.dup` }
else                  { system 'cat Io.dup' }
unlink 'Io.dup';

print STDOUT "ok 8\n";