Skip to content

refactor: use Perl 5.10 defined-or operator throughout (GH #308)#451

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/perl510-defined-or
Draft

refactor: use Perl 5.10 defined-or operator throughout (GH #308)#451
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/perl510-defined-or

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What

Replace legacy defined-based patterns with Perl 5.10's // and //= operators across 20 modules.

Why

Addresses GH #308. Perl 5.10 has been the minimum version since Makefile.PL declares MIN_PERL_VERSION => '5.010' and use 5.010. The defined-or operator (//) was introduced in 5.10 and is the idiomatic way to handle these patterns.

How

Two mechanical, semantics-preserving transformations applied across the codebase:

  1. $VAR = VAL unless defined $VAR$VAR //= VAL (26 instances)

    • All $DEBUG package variable defaults
    • $WHILE_MAX, $PRETTY, $BINMODE, $DYNAMIC, $DOCUMENT, $STAT_TTL, $MAX_DIRS
    • One local variable ($pattern in VMethods)
  2. defined $X ? $X : 'fallback'$X // 'fallback' (5 instances)

    • Debug output in Provider, Service, Plugins, Document

Patterns deliberately NOT converted:

  • Compound conditions (unless defined $x and length $x)
  • Flow control (return/last unless defined)
  • Cases where true/false branches differ in type (array deref vs scalar)
  • Grammar.pm (generated file)

Testing

Full test suite passes (2905 tests). All transformations are semantics-preserving — //= is exactly equivalent to = ... unless defined.


Quality Report

Changes: 20 files changed, 32 insertions(+), 32 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan

Replace 'VAR = VAL unless defined VAR' with 'VAR //= VAL' and
'defined X ? X : Y' with 'X // Y' across 20 modules. Perl 5.10
has been the minimum since Makefile.PL already declares it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant