Re: RFC 14 (v2) Modify open() to support FileObjects and
[email protected] (Jonathan Scott Duff) Thu, 10 Aug 2000 01:09:08 -0500
| Newsgroups | perl.perl6.language.io |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 09, 2000 at 05:45:27PM +0100, Graham Barr wrote: > > open '/usr/local/bin/'; # directory (note the trailing '/') > > Portability, not all platforms use / But this one is. If this were a Mac open ':usr:local:bin:'; # note the trailing : would Do The Right Thing. Trailing directory separator means "open this thing as a directory". > My point is that many of these protocols are more complex than I would > certain want open to handle. Leave the complex stuuf to those modules > and use the API they provide. Indeed, but Perl has to parse the fiename to find out what to do anyway, it might as well figure out what module to load from the "filename". Thus, open "http://www.perl.com"; would load the "http" module and pass the "filename" as-is to its "open" method. We could create a well-defined API to which modules must conform in order to be used in this fashion. If the user wishes to open a "file" with a protocol that doesn't have a module, it should carp in a useful way (throw an exception, set a global $ERROR variable, whatever). -Scott -- Jonathan Scott Duff [email protected]