perl-patterns

Applies modern Perl 5.36+ idioms, patterns, and best practices when writing or reviewing Perl code.

Updated Aug 17, 2026
One-click install
npx skills add https://github.com/prabaljainn/my-claude-code-setup --skill perl-patterns-prabaljainn
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: perl-patterns
Source: https://github.com/prabaljainn/my-claude-code-setup/tree/main/claude/skills/perl-patterns
Command: npx skills add https://github.com/prabaljainn/my-claude-code-setup --skill perl-patterns-prabaljainn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy Perl codebases often rely on outdated boilerplate, unsafe constructs like two-arg open, and manual argument handling, making code hard to maintain and review. This Skill provides a curated reference of modern Perl 5.36+ idioms so new and refactored code follows current conventions. ## Core Features & Use Cases - Modern Language Idioms: Covers use v5.36 pragmas, subroutine signatures, postfix dereferencing, the isa operator, and named regex captures. - Error Handling & OO Patterns: Demonstrates Try::Tiny, native try/catch (5.40+), Moo classes with type constraints, Moo roles, and the Corinna class keyword (5.38+). - Project Tooling Guidance: Includes standard module layouts, cpanfile dependency management, perltidy and perlcritic configurations, and an anti-pattern catalog. - Use Case: When migrating a legacy Perl script that uses my ($x) = @_ and two-arg open, apply this Skill to rewrite it with signatures, autodie, and Path::Tiny. ## Quick Start Review my Perl module and refactor it 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 mode, warnings, and subroutine signatures. Then convert manual `@_` unpacking to signatures and swap circumfix dereferencing for postfix syntax like `$ref->@*`.

What is the difference between Moo and Moose in Perl?▼

Moo is a lightweight object system recommended for most modern Perl applications, offering typed attributes and roles with fast startup. Moose should only be used when you need its full meta-object protocol, which Moo intentionally omits.

Does Perl have native try/catch exception handling?▼

Perl 5.40+ provides native try/catch syntax via `use v5.40`. For earlier versions, use the Try::Tiny CPAN module, which avoids the pitfalls of raw eval/die such as clobbered `$@` values.

Why is two-arg open dangerous in Perl?▼

Two-arg open embeds user data in the mode string, creating shell injection risks. Use three-arg open with an explicit mode and encoding layer, such as `open my $fh, '<:encoding(UTF-8)', $path`, ideally combined 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 dependencies.