in reply to Re: Can you tie a filehandle in your own package?
in thread Can you tie a filehandle in your own package?

This is great! (++ for you) One last question, then I'll be quiet for a while: Is there a way to change the subroutine call to use a file handle rather than a typeglob? i.e.
rdw_open(FH, "myfile") or die "Couldn't open myfile: $!";
I'd like to make this look like regular open as much as possible, and the level of peoples perl around these parts is not so great as to remember why they need the * in front of their filehandle.

Thanks,
thor

Replies are listed 'Best First'.
Re: Re: Re: Can you tie a filehandle in your own package?
by Felonious (Chaplain) on Mar 02, 2002 at 00:06 UTC
    It starts getting ugly:
    sub rdw_open(*$;@) # need a file handle and a name, but allow more for + the 3 arg open... { my $fh = shift; if (not ref($fh) eq 'GLOB') { $fh = "*" . (caller())[0] . "::" . $fh; } { no strict; tie *{$fh}, __PACKAGE__, @_ ; } }
    -- O thievish Night, Why should'st thou, but for some felonious end, In thy dark lantern thus close up the stars? --Milton