* Joshua Hoblitt ([EMAIL PROTECTED]) [20 Mar 2003 20:49]:
[...]
> Perhaps I shouldn't have been so lazy with my cut and paste of Dave's code.
Not at all =) It's given me inspiration.
> > I can see a use in, say, having an array of them. As in: try this
> > first, then this, then this, or fail.
> I agree. There are many possible ways of identifying a format so using
> a string length as the only option doesn't make any sense. I think
> your right with the array of hashes structure.
Ok. As I've currently got it:
- $class->create_parser(...)
This creates a parser coderef. Straight forward so far.
Now, the parameters make it more fun:
If given a hash:
create_parser( params => \%params, regex => qr// );
Then we assume it's a single format parser. I'll call these
arguments a 'spec' from now on. A hashref of these params is,
of course, a specref.
If given a specref as first argument, we assume it's a list of
specrefs, which will be tried in the order given.
If given a hash of number => specref, for example:
create_parser( 15 => \%ical15, 8 => \%ical8, ... );
Then a length mapping parser, like in DT::F::MySQL and DTF'ICal,
is created.
If the 'number' part isn't actually a number, i.e. label =>
specref, then the labels are sorted and the parser function
goes through in that order.
Don't worry, it's a lot simpler than I make it sound (like an Apocalypse
=) ).
> > A hash could be useful if order isn't important, and for reporting a
> > name in some sort of verbose mode:
> An array would also conveniently deal with the case of more then one
> matching format (first one wins).
And that's what's happening =)
[snip regarding AttemptAll parser]
> That could be dangerous. How do you deal with conflicts? I've had
> Date::Manip guess wrong at my date format and not find out until much
> later. I guess you could try all possible formatters and give a warn
> if more then one matches.
Good point. Scrapped. (Unless someone wants to implement it under Acme
or something =) )
> > > If someone wants to work on a Builder module, that's fine with me.
> >
> > I'll be having a play. No guarantees.
> I'm a poor coder but I'll try to help. :)
I intend to do a code release within a few hours. It won't necessarily
be complete, but it should be enough to be disparaged.
cheers,
--
Iain.