Skip to content

refactor: replace Symbol::gensym() with lexical filehandles#59

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/remove-symbol-gensym
Draft

refactor: replace Symbol::gensym() with lexical filehandles#59
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/remove-symbol-gensym

Conversation

@toddr-bot
Copy link
Copy Markdown

What

Remove all Symbol::gensym() usage and the Symbol module dependency from the codebase.

Why

Symbol::gensym() was the pre-5.6 way to create anonymous filehandle references. Since Perl 5.6,
plain lexical scalars (my $fh) work as filehandles, making gensym unnecessary. This removes a
legacy dependency and aligns with modern Perl idioms.

How

  • 4 call sites updated across Daemon.pm, Log.pm, and Test.pm
  • use Symbol () / require Symbol imports removed from all three files
  • Filehandles declared as my $fh before compound open/print/close expressions
    (not inside open()) to avoid the Perl scoping gotcha where my inside one
    operand of and/|| is invisible to subsequent operands

Testing

Full test suite passes (76 tests, 18 files).

🤖 Generated with Claude Code

Remove all Symbol::gensym() calls (4 sites across 3 files) and use plain
lexical scalars for filehandles instead. This drops the Symbol module
dependency entirely.

Note: $fh must be declared before compound open/print/close expressions
because Perl's `my` inside `open(my $fh, ...)` is not visible to
subsequent `and`/`||` operands in the same statement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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