On Thu, Aug 03, 2000 at 07:11:00AM -0600, Tom Christiansen wrote:

>     $fh = open("|-") || die "can't start pipeline: $!";
> 
>     if ($fh->pid) {
>       print $fh "stuff\n";
>     } else {
>       $data = readline $fh;
>     } 
> 
> I think I'd prefer that ->pid return 0 only to the child of a fork,
> but undef on a handle that were not the product of a fork, irrespective
> of direction.

Seems reasonable.

> Some related issues:
> 
>     1) Did Larry or did he not mention something about dealing with
>        indirect object more cleanly?

Is that a related question ? please expand.

>     2) What if any reasonable use could be put to a list context
>        return from open(), or from ->pid()?

Personally I would not like context to be introduced to open(). As
to ->pid I am not sure what you would return if it was context
sensative.

>     3) Isn't it about time to start saving the string argument to open?
>           $fh = open("< /etc/motd");
>           print $fh->filename;
>           print $fh->mode;
>           print $fh->fileno;

seems reasonable. I assume mode would return one of '<' '>' '>>'
and would would have something like $fh->type to return 'pipe','socket','file' etc.

>     4) This may become interesting for fdopens and dups.
> 
>           $fh = open("<=STDIN");
>           $fh = open("<&=STDIN");
> 
>       Oops, what about
> 
>           $fh2 = open("<=$fh1")
> 
>       that fails.   Maybe
> 
>           $fh2 = open("<=", $fh1)
> 
>       or 
> 
>           $fh2 = open($fh1->mode . "=", $fh1)
> 
>       or more clearly
> 
>           $fh2 = $fh1->dup;

I think that would be much better.

Graham.

Reply via email to