The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Sub::Mux - multiplexer to execute subs

SYNOPSIS

    use Sub::Mux;

    my $mux = Sub::Mux->new(
        sub { 'a' },
        sub { ['b'] },
    );

    $mux->push_subs( sub { 'c' } );

    $res = $mux->execute;            # 'a'

    $res = $mux->execute_all;        # ['a', ['b'], 'c']

    $res = $mux->execute_list(0, 1); # ['a', ['b'] ]

DESCRIPTION

Sub::Mux is the module for multiplex subs executer

METHODS

new(@args)

constructor

@args contains coderef list.

subs

to get subs list

execute_first, execute

executing subs and return the first result.

execute_all

execute all subs and return all results as array ref.

execute_list(@args)

execute specific subs and return the result as array ref.

@args is the list of index.

push_subs(@subs), pop_subs, unshift_subs(@subs), shift_subs

To operate the element of subs. These are similar to core functions: push, pop, unshift, shift

REPOSITORY

Sub::Mux is hosted on github <http://github.com/bayashi/Sub-Mux>

Welcome your patches and issues :D

AUTHOR

Dai Okabayashi <bayashi@cpan.org>

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.