What does this skill do?

The "Modern Patterns in Perl" skill provides a set of conventions and idiomatic patterns for writing modern Perl code (version 5.36 and later). It eliminates legacy boilerplate code through subroutine signatures, native try/catch, object-oriented programming with Moo, and safe file handling with Path::Tiny, resulting in robust and maintainable applications.

New scripts and modules
Start your Perl projects with `use v5.36` and subroutine signatures from day one, without repetitive code.
Code Review
Verify that the code complies with modern standards: no two-argument `open`, no manual unpacking of `@_`.
Refactoring Legacy Code
Migrate legacy Perl code to 5.36+ idiomatic patterns in a guided and safe manner.
Static Analysis Settings
Configure `perltidy` and `perlcritic` to automatically maintain code consistency and quality.

Usage examples

📝 Modern script
Write a Perl 5.36 script that reads a CSV file and filters the rows where the "status" column is "active," using subroutine signatures and Path::Tiny.
🔄 Refactoring
Refactor this legacy Perl module to use Moo with Types::Standard type validation and subroutine signatures.
🐛 Error Handling
Create a function that opens a file and processes its contents using Perl 5.40's native try/catch, catching read errors.
🔍 Code Review
Take a look at this Perl script and let me know what deprecated patterns it contains and how to update them to Perl 5.36+.

Features

Native subroutine signatures Validate arguments and default values directly in the signature, eliminating the need to manually unpack `@_`.
Object-Oriented Programming with Moo Classes with type validation, automatic accessors, and roles—without the complexity of Moose.
Native try/catch (Perl 5.40+) Exception handling using the language's native syntax, without relying on external modules such as Try::Tiny.
Path::Tiny for files Safe and expressive file operations, always avoiding the dangerous two-argument `open`.
Human-readable regular expressions Named captures and the `/x` modifier for maintainable, self-explanatory complex patterns.

Frequently asked questions

Yes. The skill requires Perl 5.36 or later. Some functions, such as native try/catch, require Perl 5.40 or later. The skill specifies the minimum version required for each pattern.
Yes. The skill is designed to guide the refactoring of legacy code into modern patterns in an incremental and safe manner.
Mainly Moo for OOP, Types::Standard for type validation, Path::Tiny for files, and Try::Tiny as an alternative if Perl 5.40 is not available.
Yes. The skill includes guidelines for configuring static analysis tools such as perltidy and perlcritic according to modern standards.
Modern Patterns in Perl — Clean and Robust Code with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.