On Wed, May 04, 2005 at 11:44:58PM -0700, Larry Wall wrote:
> : How do I open a file named "-"?
> 
> Um, depending on what you mean, and whether we continue to support
> the '=' pseudofile, maybe:
> 
>     $fh = io("-");
>     $fh = open "-";
>     $fh = $name eq '-' ?? $*IN :: open $name;

My concern is again with magic control. I've no gripes with the first
or last of those, but I think the second should not be allowed by
default. There has to be a safe mode for opening a file and knowing
that's what you're opening: not a pipe, not stdio (hence there are places
I can't permit myself to use #1). But as your third example suggests,
never allowing open "-" will make unixish tools tedious to write, so
maybe we need something like

    getopt(...);
    $fh = open $in, :allowstdio;

(only named more eloquently).

> : How do I open stdout (and the other standard handles)?
> 
> Maybe something like:
> 
>     $fh = open "file", :w:c:usefd(1);
>     $*OUT.reopen("file",:w:c);
>     reopen $*OUT: "file", :w:c;
> 
> give or take a few options.

What does '"file"' do in these examples? If we take your trailing-args
suggestion from the Open and pipe thread, the filename could be optional.

How to make this "-"-friendly? If my earlier suggestion is okay, then
by symmetry:

    $logfile = "-";
    open $log, :a:allowstdio;

-- 
Gaal Yahas <[EMAIL PROTECTED]>
http://gaal.livejournal.com/

Reply via email to