Date: | Tue, 22 Apr 2003 15:55:09 +0200 |
From: | Claus Färber <perl [...] faerber.muc.de> |
To: | Iain Truskett <spoon [...] cpan.org> |
Subject: | [DateTime::Format::Parser] multiple callback functions & parameter passing (patch) |
Hallo,
I have a patch to DateTime::Format::Builder (0.62) that will add the
following functionality:
- preprocess, postprocess, on_*, will all take a coderef or arrayref
(pointing to coderefs).
this allows to do the following:
@code = (\&code1, \%code2);
$parser1 = { ..., postprocess => [ @code ], };
push @code, \&code3;
$parser2 = { ..., postprocess => [ @code ], };
DateTime::Format::Builder->create_class( parsers => { 'p1'=>$parser1, 'p2'=>$parser2 };
This makes sense for more complex modules. (Yes, it will make a module
I'm writing simpler.)
- preprocess, postprocess, on_* will take two additinal parameters:
'self': allows accessing the parser object, possibly reading
configuration parameters,
e.g. from $class->new( 'european' => 1);
'param': arrayref to additional parameters passed to the
parsing functions,
e.g. from $p->parse_datetime('1/2/3', 'european' => 1);
Tests and documentation are included.
--
http://www.faerber.muc.de/
Message body is not shown because sender requested not to inline it.