Sam Tregar wrote:
>
> How is this better than File::Spec's approach?
File::Spec has the idea and representation dead on. However, the
interface is a pain; to write portable scripts you have to go through
some contortions.
With URI support, you still have to contort a little, but not as much.
Here's some better examples from an email I sent earlier:
$fo = open "file://c/docs/personal";
# Unix = /docs/personal # here, 'c' becomes '/'
# Mac = :docs:personal # here, 'c' becomes ':'
# Win = c:\docs\personal
Something like File::Spec can be used to perform the magic internally,
but you get the benefit of not having to call catfile explicitly. Perl
sees a URI and does its thing. Plus, URIs are familiar - most everyone
(even those unfamiliar with Perl) understands what the URI in the open
statement does.
Although the examples are terrible at showing it (sorry), full URI
support means more that just writing portable filenames. It means having
Perl understand http://, ftp://, etc, etc, so that it can do something
"really cool" with it. The upcoming v4 of RFC 14 will show how this is
an advantage.
-Nate