logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

DateTime::Format::Builder::Parser::Dispatch - Dispatch parsers by group

Authors

       •   Dave Rolsky <autarch@urth.org>

       •   Iain Truskett <spoon@cpan.org>

Description

       "Dispatch" adds another parser type to "Builder" permitting dispatch of parsing according to group names.

Name

       DateTime::Format::Builder::Parser::Dispatch - Dispatch parsers by group

See Also

       "datetime@perl.org" mailing list.

       http://datetime.perl.org/

       perl, DateTime, DateTime::Format::Builder

Side Effects

       Your group parser can also be a Dispatch parser. Thus you could potentially end  up  with  an  infinitely
       recursive parser.

Source

       The     source     code     repository     for     DateTime-Format-Builder     can     be     found    at
       <https://github.com/houseabsolute/DateTime-Format-Builder>.

Specification

       "Dispatch" has just one key: "Dispatch". The value should be a reference to a subroutine that returns one
       of:

       •   "undef", meaning no groups could be found.

       •   An empty list, meaning no groups could be found.

       •   A single string, meaning: use this group

       •   A list of strings, meaning: use these groups in this order.

       Groups  are  specified  much  like  the  example in the SYNOPSIS. They follow the same format as when you
       specify them for methods.

Support

       Bugs may be submitted at <https://github.com/houseabsolute/DateTime-Format-Builder/issues>.

       I am also usually active on IRC as 'autarch' on "irc://irc.perl.org".

Synopsis

           package SampleDispatch;
           use DateTime::Format::Builder (
               parsers => {
                   parse_datetime => [
                       {
                           Dispatch => sub {
                               return 'fnerk';
                           }
                       }
                   ]
               },
               groups => {
                   fnerk => [
                       {
                           regex  => qr/^(\d{4})(\d\d)(\d\d)$/,
                           params => [qw( year month day )],
                       },
                   ]
               }
           );

Version

       version 0.83

See Also