- or download this
#!/usr/bin/perl
use Socket;
...
close $sock;
}
- or download this
$ perl ./aliasing1.pl
before aliasing: sock=5, STDIN=0, STDOUT=1
after aliasing: sock=5, STDIN=5, STDOUT=5
^C
$
- or download this
$ telnet localhost 8080
Trying 127.0.0.1...
...
foo
you typed: foo
Connection closed by foreign host.
- or download this
$ perl -d ./aliasing1.pl
...
328: sub DESTROY {}
DB<1> q
$
- or download this
POSIX::dup2(fileno($sock), 0) or die "Cannot dup sock to STDIN: $!";
POSIX::dup2(fileno($sock), 1) or die "Cannot dup sock to STDOUT: $!";
- or download this
open STDIN, "<&", $sock or die "Cannot dup sock to STDIN: $!";
open STDOUT, ">&", $sock or die "Cannot dup sock to STDOUT: $!";
- or download this
#!/usr/bin/perl
...
fileno($fh), fileno(STDOUT);
print "foo\n";
- or download this
$ perl ./aliasing2.pl
fds before aliasing: fh=3, STDOUT=1
fds after aliasing: fh=3, STDOUT=3
- or download this
$ perl -d ./aliasing2.pl
...
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1> q