TAP::Pa...iplexer(3pm)

✨ TAP::Parser::Multiplexer ✨

okay bestie, welcome to the TAP::Parser::Multiplexer page from the Perl Programmers Reference Guide β€” yes it's a real manpage, yes it's 3pm-coded, yes we're doing this πŸ’…

🌸 NAME 🌸

TAP::Parser::Multiplexer β€” literally multiplexing multiple TAP::Parsers, that's the whole vibe πŸ¦‹

⭐ VERSION ⭐

Version 3.50 β€” iconic, no notes, periodt πŸ‘‘

πŸŽ€ SYNOPSIS πŸŽ€

here's the whole thing in action, copy it exactly bestie:

use TAP::Parser::Multiplexer;

my $mux = TAP::Parser::Multiplexer->new;
$mux->add( $parser1, $stash1 );
$mux->add( $parser2, $stash2 );
while ( my ( $parser, $stash, $result ) = $mux->next ) {
    # do stuff
}

like… while loop, $mux->next, # do stuff β€” the whole main character energy is in there 🫢

πŸ’– DESCRIPTION πŸ’–

So TAP::Parser::Multiplexer gathers input from multiple TAP::Parsers. That's its job, that's its whole thing. 🌈

Internally, it calls select on the input file handles for those parsers, so it can wait for one or more of them to have input available. Not me being obsessed with a syscall 😭 but like… select is lowkey the moment.

Wanna see an example of its use? Go look at TAP::Harness, it's right there, it's giving role model ✨


🧚 METHODS 🧚

πŸ‘‘ Class Methods πŸ‘‘

new

my $mux = TAP::Parser::Multiplexer->new;

Returns a new TAP::Parser::Multiplexer object. Fresh out the box, brand new, glowing, slay πŸ’…

πŸ¦‹ Instance Methods πŸ¦‹

add

$mux->add( $parser, $stash );

Add a TAP::Parser to the multiplexer. $stash is an optional opaque reference β€” it comes back to you from next along with the parser and the next result. so it's like, your little secret payload, iykyk πŸ“

parsers

my $count   = $mux->parsers;

Returns the number of parsers. Heads up bestie: parsers get removed from the multiplexer when their input is exhausted. they literally leave the group chat when they run out of things to say πŸ’€

next

Return a result from the next available parser. It returns a list containing the parser the result came from, the stash that corresponds with that parser, and the result. all three, packaged, delivered 🎁

my ( $parser, $stash, $result ) = $mux->next;

If $result is undefined, that corresponding parser has reached the end of its input β€” and ngl it will automatically be removed from the multiplexer, no cap. 🫑

When all parsers are exhausted, an empty list gets returned. everybody's done, the party's over, the lights are on πŸŒ™

if ( my ( $parser, $stash, $result ) = $mux->next ) {
    if ( ! defined $result ) {
        # End of this parser
    }
    else {
        # Process result
    }
}
else {
    # All parsers finished
}

that if/else structure is doing the absolute most and honestly? it ate πŸ’–


πŸ”₯ See Also πŸ”₯

  • TAP::Parser
  • TAP::Harness

okay that's the whole page, you read it all, you understood it all, you're basically a multiplexer now πŸ‘‘

signing off: this was perl v5.42.3, dated 2026-11-03, and the page itself is TAP::Parser::Multiplexer(3pm) β€” ily, go multiplex something πŸ’œπŸŒΈβœ¨

πŸ“¦ where this page comes from