perl-patterns

Applies modern Perl 5.36+ idioms and best practices to writing and refactoring Perl code.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill perl-patterns-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perl-patterns
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/perl-patterns
Command: npx skills add https://github.com/ibytechaos/claude --skill perl-patterns-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy Perl code often relies on outdated boilerplate, unsafe constructs like two-argument open, and manual argument unpacking, making it hard to maintain and error-prone. This Skill guides writing and refactoring Perl using modern 5.36+ conventions. ## Core Features & Use Cases - Modern Idioms: Enforces use v5.36, subroutine signatures, postfix dereferencing, named regex captures, and the isa operator. - OO and Error Handling: Covers Moo classes and roles, Try::Tiny, native try/catch (5.40+), and the Corinna class keyword (5.38+). - Tooling & Structure: Provides perltidy/perlcritic configs, cpanfile dependency management with Carton, and standard project layout. - Use Case: When migrating a legacy Perl script that uses use strict, manual @_ unpacking, and blessed hashrefs, apply this Skill to rewrite it with signatures, Moo classes, and Path::Tiny file handling. ## Quick Start Refactor my legacy Perl script to use modern Perl 5.36 idioms including signatures, Moo, and safe file handling.

Frequently Asked Questions about perl-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I modernize legacy Perl code to Perl 5.36?

Replace the strict/warnings boilerplate with a single `use v5.36` pragma, which enables strict, warnings, and subroutine signatures. Then convert manual `@_` unpacking to signatures, switch circumfix dereferencing to postfix syntax, and replace blessed hashrefs with Moo classes.

What is the difference between Moo and Moose in Perl?

Moo is a lightweight object system with fast startup and a subset of Moose features, making it the preferred default for most applications. Use Moose only when you need its full metaprotocol, such as advanced introspection or meta-class manipulation.

How do I handle exceptions in modern Perl?

Use Try::Tiny for reliable try/catch semantics on Perl 5.36, since plain eval/die has edge cases with $@ clobbering. On Perl 5.40 and later, the native try/catch syntax is available without external modules.

Why is two-argument open dangerous in Perl?

Two-argument open embeds the mode in the filename string, allowing shell metacharacters in user-controlled paths to trigger unintended behavior. Always use three-argument open with an explicit mode like `open my $fh, '<:encoding(UTF-8)', $path`, ideally combined with autodie.

Does Perl 5.36 support subroutine signatures without experimental warnings?

Yes, subroutine signatures are stable in Perl 5.36 and enabled automatically by `use v5.36` without any experimental warnings. They provide automatic arity checking and support default values and slurpy parameters.

How do I manage Perl module dependencies for a project?

Declare dependencies in a cpanfile with version constraints, then use Carton to install them into a local directory. Run scripts with `carton exec -- perl bin/myapp` to ensure the pinned dependency set is used.