perl-patterns

Applies modern Perl 5.36+ idioms, Moo OO patterns, and safe coding conventions to Perl codebases.

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/Femad-6/my-skills --skill perl-patterns-femad-6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perl-patterns
Source: https://github.com/Femad-6/my-skills/tree/main/.github/skills/perl-patterns
Command: npx skills add https://github.com/Femad-6/my-skills --skill perl-patterns-femad-6

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy Perl code often relies on outdated boilerplate, unsafe constructs like two-arg open, and manual argument handling, making it hard to maintain and error-prone. This Skill provides a consistent set of modern Perl 5.36+ patterns for writing, reviewing, and refactoring Perl code. ## Core Features & Use Cases - Modern Language Idioms: Covers use v5.36, subroutine signatures, postfix dereferencing, named regex captures, the isa operator, and native try/catch for Perl 5.40+. - OO and Error Handling: Provides Moo class and role patterns, Corinna class syntax, and Try::Tiny-based exception handling. - Tooling and Project Layout: Includes perltidy/perlcritic configs, cpanfile dependency management with Carton, standard module layout, and a legacy-to-modern idiom reference table. - Use Case: When refactoring a legacy Perl script that uses open FH, $file and blessed hashrefs, apply this Skill to convert it to three-arg open with autodie and a typed Moo class. ## Quick Start Review my Perl module and refactor it to use modern Perl 5.36 idioms with signatures and Moo classes.

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 two-arg open with three-arg open.

Should I use Moo or Moose for Perl object-oriented code?

Prefer Moo for lightweight modern OO with type constraints via Types::Standard, and use Moose only when its metaprotocol is required. For Perl 5.38+, the native Corinna `class` keyword with `use feature 'class'` is another option.

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+, the native `try`/`catch ($e)` syntax is available without external modules.

Why is two-argument open dangerous in Perl?

Two-arg open embeds the mode in the filename string, so user-controlled data can inject shell commands or unintended modes. Use three-argument open with an explicit mode like `'<:encoding(UTF-8)'` and a lexical filehandle, ideally with autodie.

How do I manage Perl module dependencies with cpanfile?

Declare dependencies in a cpanfile with version constraints, then run `carton install` to install them into a local directory. Execute scripts with `carton exec -- perl bin/myapp` so they use the pinned local dependency set.