Syntax-Infix-ConditionalSplice

A lexically-scoped, short-circuiting `?|` operator for splicing elements into a
list conditionally.

    use Syntax::Infix::ConditionalSplice;

    my @cmd = (
        'prog',
        $verbose   ?| '--verbose',         # included only when $verbose
        $jobs > 1  ?| ('--jobs', $jobs),    # a whole sub-list, conditionally
        @files,
    );

`COND ?| LIST` is `COND ? LIST : ()` -- LIST when COND is true, the empty list
otherwise -- but reads as one quiet element in the middle of a list rather than
a parenthesised ternary with an easily-forgotten `: ()` tail.

It is built on Infix::Custom's C-level build_op escape hatch, because it does two
things a function call can't: it SHORT-CIRCUITS (LIST is only evaluated when COND
is true) and it is CONTEXT-AWARE (the list flattens in list context, yields its
last value or undef in scalar context). The implementation is one line of C:

    return newCONDOP(0, lhs, rhs, newOP(OP_STUB, 0));

It binds at assignment precedence: tighter than comma (so `$c ?| 'x'` is one
list element) but looser than the comparison/logical operators (so the condition
can be `$n > 3` without parentheses).


REQUIREMENTS

Requires perl 5.38 or newer (for the core PL_infix_plugin hook that
Infix::Custom uses) and Infix::Custom itself. Does not install on older perls.
No other dependencies.


INSTALLATION

    perl Makefile.PL
    make
    make test
    make install


LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION <email@lnation.org>.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)
