DOKK / manpages / debian 10 / libdatetime-format-builder-perl / DateTime::Format::Builder::Parser::Dispatch.3pm.en
DateTime::Format::Builder::Parser::Dispatch(3pm) User Contributed Perl Documentation DateTime::Format::Builder::Parser::Dispatch(3pm)

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

version 0.81

    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 )],
                },
            ]
        }
    );

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

"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.

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

See DateTime::Format::Builder for details.

"datetime@perl.org" mailing list.

http://datetime.perl.org/

perl, DateTime, DateTime::Format::Builder

  • Dave Rolsky <autarch@urth.org>
  • Iain Truskett

This software is Copyright (c) 2013 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
2018-08-25 perl v5.26.2