>Modify open() and opendir() to return filehandle objects

Here are some things that that will be a problem for:

    open(SESAME, "| output-pipe-command")  # set up an output filter
    open(SESAME, "input-pipe-command |")   # set up an input filter
    open SPOOLER, "| cat -v | lpr -h 2>/dev/null"
    open SPOOLER, "|-", "lpr", "-h"
    open(STDOUT, "| $pager")    or die "can't fork a pager: $!";
    open STATUS, "netstat -an 2>/dev/null |"
    open STATUS, "-|", "netstat", "-an"
    open(PROG_TO_READ_AND_WRITE, "| some program |")  # WRONG!
    open(OOF, "echo $arg|")       # Insecure due to tainted $arg, but...
    open(OOF,"-|")                # Considered OK: see below for taint
    open(OOF,"-|", 'echo', $arg   # Same as previous, likewise OKish.
    open(FROMKID, "-|") or exec("myprog", "arg1", "arg2")
    open(FROMKID, "-|", "myprog", "arg1", "arg2");
    open(MAIL, '|/usr/lib/sendmail -t') or die "cannot fork sendmail: $!";
    open(OUTPUT, '| sort -rn | lpr -p') # pipe to sort and lpr
    open(NETSTAT, "netstat -rn |")
    open(PRINTER, "| lpr -Plp1")    or die "can't fork: $!";
    open(NET, "netstat -i -n |")    or die "can't fork: $!";
    open(PRINTER, "|-", "lpr -Plp1")    or die "can't fork: $!";
    open(NET, "-|", "netstat -i -n")    or die "can't fork: $!";
    open(PRINTER, "|-", "lpr", "-Plp1")    or die "can't fork: $!";
    open(NET, "-|", "netstat", "-i", "-n") or die "can't fork: $!";
    open FH,            "| tr   'a-z'  'A-Z'";        # to shell command
    open FH, "|-",        'tr', 'a-z', 'A-Z';         # to bare command
    open FH, "|-" or exec 'tr', 'a-z', 'A-Z' or die;  # to child
    open FH,              "cat    -n   'file' |";     # from shell command
    open FH, "-|",        'cat', '-n', 'file';        # from bare command
    open FH, "-|" or exec 'cat', '-n', 'file' or die; # from child

Note than N-arg open remains pre-documented.

--tom

Reply via email to