DateTim...Dispatch(3)

πŸ¦‹ DateTim...Dispatch(3) β€” the dispatch parser one

okay so real talk, this is a User Contributed Perl Documentation page for DateTime::Format::Builder::Parser::Dispatch, and honestly? It's a whole vibe. Stay with me bestie, it's shorter than it looks πŸ’–


✨ NAME ✨

DateTime::Format::Builder::Parser::Dispatch β€” Dispatch parsers by group. That's it, that's the whole thing, and it ate πŸ’…


🌸 VERSION 🌸

version 0.83


πŸŽ€ SYNOPSIS πŸŽ€

like, just look at it. it's giving main character energy:

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

no cap, 'fnerk' is literally a group name here and I'm obsessed πŸ“


πŸ’œ DESCRIPTION πŸ’œ

so Dispatch is out here adding another parser type to Builder, and what it does is permit dispatch of parsing according to group names. Slay. It's literally in the name, iykyk.


πŸ”₯ SPECIFICATION πŸ”₯

Dispatch has just one key: Dispatch. One key! Minimalist icon ✨

The value should be a reference to a subroutine, and that sub returns one of these four things:

  • undef β€” meaning no groups could be found πŸ™ˆ
  • An empty list β€” also meaning no groups could be found (same energy, different shape πŸ’€)
  • 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 up in the SYNOPSIS. They follow the same format as when you specify them for methods. Fr fr, same format.


πŸ’€ SIDE EFFECTS πŸ’€

bestie. listen. Your group parser can also be a Dispatch parser. Thus you could potentially end up with an infinitely recursive parser. Not me warning you dramatically, but like… I am warning you dramatically 😭

🌈 SEE ALSO 🌈


🫢 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. come say hi πŸ’–


⭐ SOURCE ⭐

The source code repository for DateTime-Format-Builder can be found at https://github.com/houseabsolute/DateTime-Format-Builder. go peek, it's right there πŸŽ€


πŸ‘‘ AUTHORS πŸ‘‘

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

two icons, one module πŸ’…


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

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the LICENSE file included with this distribution. read it, it's good for you 🧚


and that's the whole page bestie!! brought to you by perl v5.40.0, dated 2023-01-15, and the DateTim...Dispatch(3) girlies πŸ’œβœ¨ mwah, go parse something cute πŸ¦‹

πŸ“¦ where this page comes from