VERSION

version 0.81

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

DESCRIPTION

\*(C`Dispatch\*(C' adds another parser type to \*(C`Builder\*(C' permitting dispatch of parsing according to group names.

SPECIFICATION

\*(C`Dispatch\*(C' has just one key: \*(C`Dispatch\*(C'. The value should be a reference to a subroutine that returns one of:

  • \*(C`undef\*(C', 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 \s-1SYNOPSIS\s0. They follow the same format as when you specify them for methods.

SIDEEFFECTS

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

SUPPORT

See DateTime::Format::Builder for details.

RELATED TO DateTime::Format::Builder::Parser::Dispatch…

\*(C`[email protected]\*(C' mailing list.

http://datetime.perl.org/

perl, DateTime, DateTime::Format::Builder

AUTHORS

COPYRIGHT AND LICENSE

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

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)