Syntax-Infix-OptionalChain

A lexically-scoped safe-navigation operator `?->` for Perl, that works across
blessed objects, plain hash references and plain array references.

    use Syntax::Infix::OptionalChain;

    $object   ?-> method      # $object->method     (blessed -> method call)
    $hashref  ?-> key         # $hashref->{key}     (HASH ref -> element)
    $arrayref ?-> 0           # $arrayref->[0]      (ARRAY ref -> element)

    # chains short-circuit at the first undef, and combine with // :
    my $port = $config ?-> servers ?-> 0 ?-> port // 8080;

Each step is dispatched by what the left operand actually is at run time. An
undef invocant short-circuits the whole chain to undef; a missing hash key or
out-of-range index is undef; an unknown method, or a defined-but-un-navigable
value, is a clear error rather than being silently swallowed.

The operator is built on Infix::Custom and is lexically scoped: it exists only
where the module is used.


REQUIREMENTS

Requires perl 5.38 or newer (for the core PL_infix_plugin hook that
Infix::Custom uses) and Infix::Custom itself. The operator is the module's only
purpose, so it does not install on older perls. No other dependencies.


INSTALLATION

    perl Makefile.PL
    make
    make test
    make install


SUPPORT AND DOCUMENTATION

    perldoc Syntax::Infix::OptionalChain


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)
