I definitely believe URI resource manipulation is what p5ee should
discuss about, but I couldn't find API draft for it. (So point me if I
miss anything.)

In a word, why does URI module miss "get_data()" (or get_handle())
method?

As a module writer, it's bothered me how to define API which points to
some "resource". For example in Mac::Macbinary, new() accepts three
type of argument:

  1. file path (like /path/to/file)
  2. file handle (or IO::* object)
  3. raw data as a scalar reference

So it results in ugly if ... elsif ... elsif ... in new().

As a module user, it's botherd me how to pass argument to module,
without a hassle in looking at module's perldoc. So if I get data via
HTTP and convert it with Some::Conv which accepts raw data as a scalar
reference, I should code something like:

  use LWP::Simple;
  use Some::Conv;

  my $data = get $url;
  my $conv = Some::Conv->new(\$data);

What bothers me is inconsistency of API amongst various modules. So we
need Universal API to define some "resource". It is what URI is about.

Defining get_data() or get_handle() in URI class will reduce these
hassles amongst module's developers/users:

  my $uri = URI->new('file://path/to/file');
  my $data = Some::Module->new($uri);


SEE ALSO:
* URI class in Java
  http://java.sun.com/j2se/1.4/docs/api/java/net/URI.html
* fopen() function in PHP
  http://www.php.net/manual/en/function.fopen.php

-- 
Tatsuhiko Miyagawa

Reply via email to