Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    use Socket;
    ...
    
        close $sock;
    }
    
  2. or download this
    $ perl ./aliasing1.pl
    before aliasing: sock=5, STDIN=0, STDOUT=1
    after aliasing:  sock=5, STDIN=5, STDOUT=5
    ^C
    $
    
  3. or download this
    $ telnet localhost 8080
    Trying 127.0.0.1...
    ...
    foo
    you typed: foo
    Connection closed by foreign host.
    
  4. or download this
    $ perl -d ./aliasing1.pl
    
    ...
    328:    sub DESTROY {}
      DB<1> q
    $
    
  5. 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: $!";
    
  6. or download this
    open STDIN,  "<&", $sock or die "Cannot dup sock to STDIN: $!";
    open STDOUT, ">&", $sock or die "Cannot dup sock to STDOUT: $!";
    
  7. or download this
    #!/usr/bin/perl
    
    ...
                  fileno($fh), fileno(STDOUT);
    
    print "foo\n";
    
  8. or download this
    $ perl ./aliasing2.pl
    fds before aliasing: fh=3, STDOUT=1
    fds after aliasing:  fh=3, STDOUT=3
    
  9. 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