[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79PPN2ZNDBYCE6XCSZRYRN1":3,"skill-same:01M79PPN2ZNDBYCE6XCSZRYRN1":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":14,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M79PPN2ZNDBYCE6XCSZRYRN1","perl-patterns",null,"Modern Perl 5.36+ idioms, best practices, and conventions for building robust, maintainable Perl applications. Use when writing or reviewing modern Perl 5.36+ code.","JunMystery\u002FAgent-Guidance","JunMystery","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F161468934?v=4","01M79MTMV8F0BY8NK1A92RA8A0","Jun","01M79MTMWCFBKPHN5B25E6V20B",0,"MIT","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fperl-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: perl-patterns\ndescription: Modern Perl 5.36+ idioms, best practices, and conventions for building robust, maintainable Perl applications. Use when writing or reviewing modern Perl 5.36+ code.\nmetadata:\n  origin: ECC\n---\n\n# Modern Perl Development Patterns\n\nIdiomatic Perl 5.36+ patterns and best practices for building robust, maintainable applications.\n\n## When to Activate\n\n- Writing new Perl code or modules\n- Reviewing Perl code for idiom compliance\n- Refactoring legacy Perl to modern standards\n- Designing Perl module architecture\n- Migrating pre-5.36 code to modern Perl\n\n## How It Works\n\nApply these patterns as a bias toward modern Perl 5.36+ defaults: signatures, explicit modules, focused error handling, and testable boundaries. The examples below are meant to be copied as starting points, then tightened for the actual app, dependency stack, and deployment model in front of you.\n\n## Core Principles\n\n### 1. Use `v5.36` Pragma\n\nA single `use v5.36` replaces the old boilerplate and enables strict, warnings, and subroutine signatures.\n\n```perl\n# Good: Modern preamble\nuse v5.36;\n\nsub greet($name) {\n    say \"Hello, $name!\";\n}\n\n# Bad: Legacy boilerplate\nuse strict;\nuse warnings;\nuse feature 'say', 'signatures';\nno warnings 'experimental::signatures';\n\nsub greet {\n    my ($name) = @_;\n    say \"Hello, $name!\";\n}\n```\n\n### 2. Subroutine Signatures\n\nUse signatures for clarity and automatic arity checking.\n\n```perl\nuse v5.36;\n\n# Good: Signatures with defaults\nsub connect_db($host, $port = 5432, $timeout = 30) {\n    # $host is required, others have defaults\n    return DBI->connect(\"dbi:Pg:host=$host;port=$port\", undef, undef, {\n        RaiseError => 1,\n        PrintError => 0,\n    });\n}\n\n# Good: Slurpy parameter for variable args\nsub log_message($level, @details) {\n    say \"[$level] \" . join(' ', @details);\n}\n\n# Bad: Manual argument unpacking\nsub connect_db {\n    my ($host, $port, $timeout) = @_;\n    $port    \u002F\u002F= 5432;\n    $timeout \u002F\u002F= 30;\n    # ...\n}\n```\n\n### 3. Context Sensitivity\n\nUnderstand scalar vs list context — a core Perl concept.\n\n```perl\nuse v5.36;\n\nmy @items = (1, 2, 3, 4, 5);\n\nmy @copy  = @items;            # List context: all elements\nmy $count = @items;            # Scalar context: count (5)\nsay \"Items: \" . scalar @items; # Force scalar context\n```\n\n### 4. Postfix Dereferencing\n\nUse postfix dereference syntax for readability with nested structures.\n\n```perl\nuse v5.36;\n\nmy $data = {\n    users => [\n        { name => 'Alice', roles => ['admin', 'user'] },\n        { name => 'Bob',   roles => ['user'] },\n    ],\n};\n\n# Good: Postfix dereferencing\nmy @users = $data->{users}->@*;\nmy @roles = $data->{users}[0]{roles}->@*;\nmy %first = $data->{users}[0]->%*;\n\n# Bad: Circumfix dereferencing (harder to read in chains)\nmy @users = @{ $data->{users} };\nmy @roles = @{ $data->{users}[0]{roles} };\n```\n\n### 5. The `isa` Operator (5.32+)\n\nInfix type-check — replaces `blessed($o) && $o->isa('X')`.\n\n```perl\nuse v5.36;\nif ($obj isa 'My::Class') { $obj->do_something }\n```\n\n## Error Handling\n\n### eval\u002Fdie Pattern\n\n```perl\nuse v5.36;\n\nsub parse_config($path) {\n    my $content = eval { path($path)->slurp_utf8 };\n    die \"Config error: $@\" if $@;\n    return decode_json($content);\n}\n```\n\n### Try::Tiny (Reliable Exception Handling)\n\n```perl\nuse v5.36;\nuse Try::Tiny;\n\nsub fetch_user($id) {\n    my $user = try {\n        $db->resultset('User')->find($id)\n            \u002F\u002F die \"User $id not found\\n\";\n    }\n    catch {\n        warn \"Failed to fetch user $id: $_\";\n        undef;\n    };\n    return $user;\n}\n```\n\n### Native try\u002Fcatch (5.40+)\n\n```perl\nuse v5.40;\n\nsub divide($x, $y) {\n    try {\n        die \"Division by zero\" if $y == 0;\n        return $x \u002F $y;\n    }\n    catch ($e) {\n        warn \"Error: $e\";\n        return;\n    }\n}\n```\n\n## Modern OO with Moo\n\nPrefer Moo for lightweight, modern OO. Use Moose only when its metaprotocol is needed.\n\n```perl\n# Good: Moo class\npackage User;\nuse Moo;\nuse Types::Standard qw(Str Int ArrayRef);\nuse namespace::autoclean;\n\nhas name  => (is => 'ro', isa => Str, required => 1);\nhas email => (is => 'ro', isa => Str, required => 1);\nhas age   => (is => 'ro', isa => Int, default  => sub { 0 });\nhas roles => (is => 'ro', isa => ArrayRef[Str], default => sub { [] });\n\nsub is_admin($self) {\n    return grep { $_ eq 'admin' } $self->roles->@*;\n}\n\nsub greet($self) {\n    return \"Hello, I'm \" . $self->name;\n}\n\n1;\n\n# Usage\nmy $user = User->new(\n    name  => 'Alice',\n    email => 'alice@example.com',\n    roles => ['admin', 'user'],\n);\n\n# Bad: Blessed hashref (no validation, no accessors)\npackage User;\nsub new {\n    my ($class, %args) = @_;\n    return bless \\%args, $class;\n}\nsub name { return $_[0]->{name} }\n1;\n```\n\n### Moo Roles\n\n```perl\npackage Role::Serializable;\nuse Moo::Role;\nuse JSON::MaybeXS qw(encode_json);\nrequires 'TO_HASH';\nsub to_json($self) { encode_json($self->TO_HASH) }\n1;\n\npackage User;\nuse Moo;\nwith 'Role::Serializable';\nhas name  => (is => 'ro', required => 1);\nhas email => (is => 'ro', required => 1);\nsub TO_HASH($self) { { name => $self->name, email => $self->email } }\n1;\n```\n\n### Native `class` Keyword (5.38+, Corinna)\n\n```perl\nuse v5.38;\nuse feature 'class';\nno warnings 'experimental::class';\n\nclass Point {\n    field $x :param;\n    field $y :param;\n    method magnitude() { sqrt($x**2 + $y**2) }\n}\n\nmy $p = Point->new(x => 3, y => 4);\nsay $p->magnitude;  # 5\n```\n\n## Regular Expressions\n\n### Named Captures and `\u002Fx` Flag\n\n```perl\nuse v5.36;\n\n# Good: Named captures with \u002Fx for readability\nmy $log_re = qr{\n    ^ (?\u003Ctimestamp> \\d{4}-\\d{2}-\\d{2} \\s \\d{2}:\\d{2}:\\d{2} )\n    \\s+ \\[ (?\u003Clevel> \\w+ ) \\]\n    \\s+ (?\u003Cmessage> .+ ) $\n}x;\n\nif ($line =~ $log_re) {\n    say \"Time: $+{timestamp}, Level: $+{level}\";\n    say \"Message: $+{message}\";\n}\n\n# Bad: Positional captures (hard to maintain)\nif ($line =~ \u002F^(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})\\s+\\[(\\w+)\\]\\s+(.+)$\u002F) {\n    say \"Time: $1, Level: $2\";\n}\n```\n\n### Precompiled Patterns\n\n```perl\nuse v5.36;\n\n# Good: Compile once, use many\nmy $email_re = qr\u002F^[A-Za-z0-9._%+-]+\\@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$\u002F;\n\nsub validate_emails(@emails) {\n    return grep { $_ =~ $email_re } @emails;\n}\n```\n\n## Data Structures\n\n### References and Safe Deep Access\n\n```perl\nuse v5.36;\n\n# Hash and array references\nmy $config = {\n    database => {\n        host => 'localhost',\n        port => 5432,\n        options => ['utf8', 'sslmode=require'],\n    },\n};\n\n# Safe deep access (returns undef if any level missing)\nmy $port = $config->{database}{port};           # 5432\nmy $missing = $config->{cache}{host};           # undef, no error\n\n# Hash slices\nmy %subset;\n@subset{qw(host port)} = @{$config->{database}}{qw(host port)};\n\n# Array slices\nmy @first_two = $config->{database}{options}->@[0, 1];\n\n# Multi-variable for loop (experimental in 5.36, stable in 5.40)\nuse feature 'for_list';\nno warnings 'experimental::for_list';\nfor my ($key, $val) (%$config) {\n    say \"$key => $val\";\n}\n```\n\n## File I\u002FO\n\n### Three-Argument Open\n\n```perl\nuse v5.36;\n\n# Good: Three-arg open with autodie (core module, eliminates 'or die')\nuse autodie;\n\nsub read_file($path) {\n    open my $fh, '\u003C:encoding(UTF-8)', $path;\n    local $\u002F;\n    my $content = \u003C$fh>;\n    close $fh;\n    return $content;\n}\n\n# Bad: Two-arg open (shell injection risk, see perl-security)\nopen FH, $path;            # NEVER do this\nopen FH, \"\u003C $path\";        # Still bad — user data in mode string\n```\n\n### Path::Tiny for File Operations\n\n```perl\nuse v5.36;\nuse Path::Tiny;\n\nmy $file = path('config', 'app.json');\nmy $content = $file->slurp_utf8;\n$file->spew_utf8($new_content);\n\n# Iterate directory\nfor my $child (path('src')->children(qr\u002F\\.pl$\u002F)) {\n    say $child->basename;\n}\n```\n\n## Module Organization\n\n### Standard Project Layout\n\n```text\nMyApp\u002F\n├── lib\u002F\n│   └── MyApp\u002F\n│       ├── App.pm           # Main module\n│       ├── Config.pm        # Configuration\n│       ├── DB.pm            # Database layer\n│       └── Util.pm          # Utilities\n├── bin\u002F\n│   └── myapp                # Entry-point script\n├── t\u002F\n│   ├── 00-load.t            # Compilation tests\n│   ├── unit\u002F                # Unit tests\n│   └── integration\u002F         # Integration tests\n├── cpanfile                 # Dependencies\n├── Makefile.PL              # Build system\n└── .perlcriticrc            # Linting config\n```\n\n### Exporter Patterns\n\n```perl\npackage MyApp::Util;\nuse v5.36;\nuse Exporter 'import';\n\nour @EXPORT_OK   = qw(trim);\nour %EXPORT_TAGS = (all => \\@EXPORT_OK);\n\nsub trim($str) { $str =~ s\u002F^\\s+|\\s+$\u002F\u002Fgr }\n\n1;\n```\n\n## Tooling\n\n### perltidy Configuration (.perltidyrc)\n\n```text\n-i=4        # 4-space indent\n-l=100      # 100-char line length\n-ci=4       # continuation indent\n-ce         # cuddled else\n-bar        # opening brace on same line\n-nolq       # don't outdent long quoted strings\n```\n\n### perlcritic Configuration (.perlcriticrc)\n\n```ini\nseverity = 3\ntheme = core + pbp + security\n\n[InputOutput::RequireCheckedSyscalls]\nfunctions = :builtins\nexclude_functions = say print\n\n[Subroutines::ProhibitExplicitReturnUndef]\nseverity = 4\n\n[ValuesAndExpressions::ProhibitMagicNumbers]\nallowed_values = 0 1 2 -1\n```\n\n### Dependency Management (cpanfile + carton)\n\n```bash\ncpanm App::cpanminus Carton   # Install tools\ncarton install                 # Install deps from cpanfile\ncarton exec -- perl bin\u002Fmyapp  # Run with local deps\n```\n\n```perl\n# cpanfile\nrequires 'Moo', '>= 2.005';\nrequires 'Path::Tiny';\nrequires 'JSON::MaybeXS';\nrequires 'Try::Tiny';\n\non test => sub {\n    requires 'Test2::V0';\n    requires 'Test::MockModule';\n};\n```\n\n## Quick Reference: Modern Perl Idioms\n\n| Legacy Pattern | Modern Replacement |\n|---|---|\n| `use strict; use warnings;` | `use v5.36;` |\n| `my ($x, $y) = @_;` | `sub foo($x, $y) { ... }` |\n| `@{ $ref }` | `$ref->@*` |\n| `%{ $ref }` | `$ref->%*` |\n| `open FH, \"\u003C $file\"` | `open my $fh, '\u003C:encoding(UTF-8)', $file` |\n| `blessed hashref` | `Moo` class with types |\n| `$1, $2, $3` | `$+{name}` (named captures) |\n| `eval { }; if ($@)` | `Try::Tiny` or native `try\u002Fcatch` (5.40+) |\n| `BEGIN { require Exporter; }` | `use Exporter 'import';` |\n| Manual file ops | `Path::Tiny` |\n| `blessed($o) && $o->isa('X')` | `$o isa 'X'` (5.32+) |\n| `builtin::true \u002F false` | `use builtin 'true', 'false';` (5.36+, experimental) |\n\n## Anti-Patterns\n\n```perl\n# 1. Two-arg open (security risk)\nopen FH, $filename;                     # NEVER\n\n# 2. Indirect object syntax (ambiguous parsing)\nmy $obj = new Foo(bar => 1);            # Bad\nmy $obj = Foo->new(bar => 1);           # Good\n\n# 3. Excessive reliance on $_\nmap { process($_) } grep { validate($_) } @items;  # Hard to follow\nmy @valid = grep { validate($_) } @items;           # Better: break it up\nmy @results = map { process($_) } @valid;\n\n# 4. Disabling strict refs\nno strict 'refs';                        # Almost always wrong\n${\"My::Package::$var\"} = $value;         # Use a hash instead\n\n# 5. Global variables as configuration\nour $TIMEOUT = 30;                       # Bad: mutable global\nuse constant TIMEOUT => 30;              # Better: constant\n# Best: Moo attribute with default\n\n# 6. String eval for module loading\neval \"require $module\";                  # Bad: code injection risk\neval \"use $module\";                      # Bad\nuse Module::Runtime 'require_module';    # Good: safe module loading\nrequire_module($module);\n```\n\n**Remember**: Modern Perl is clean, readable, and safe. Let `use v5.36` handle the boilerplate, use Moo for objects, and prefer CPAN's battle-tested modules over hand-rolled solutions.\n","# Modern Perl Development Patterns\n\nIdiomatic Perl 5.36+ patterns and best practices for building robust, maintainable applications.\n\n## When to Activate\n\n- Writing new Perl code or modules\n- Reviewing Perl code for idiom compliance\n- Refactoring legacy Perl to modern standards\n- Designing Perl module architecture\n- Migrating pre-5.36 code to modern Perl\n\n## How It Works\n\nApply these patterns as a bias toward modern Perl 5.36+ defaults: signatures, explicit modules, focused error handling, and testable boundaries. The examples below are meant to be copied as starting points, then tightened for the actual app, dependency stack, and deployment model in front of you.\n\n## Core Principles\n\n### 1. Use `v5.36` Pragma\n\nA single `use v5.36` replaces the old boilerplate and enables strict, warnings, and subroutine signatures.\n\n```perl\n# Good: Modern preamble\nuse v5.36;\n\nsub greet($name) {\n    say \"Hello, $name!\";\n}\n\n# Bad: Legacy boilerplate\nuse strict;\nuse warnings;\nuse feature 'say', 'signatures';\nno warnings 'experimental::signatures';\n\nsub greet {\n    my ($name) = @_;\n    say \"Hello, $name!\";\n}\n```\n\n### 2. Subroutine Signatures\n\nUse signatures for clarity and automatic arity checking.\n\n```perl\nuse v5.36;\n\n# Good: Signatures with defaults\nsub connect_db($host, $port = 5432, $timeout = 30) {\n    # $host is required, others have defaults\n    return DBI->connect(\"dbi:Pg:host=$host;port=$port\", undef, undef, {\n        RaiseError => 1,\n        PrintError => 0,\n    });\n}\n\n# Good: Slurpy parameter for variable args\nsub log_message($level, @details) {\n    say \"[$level] \" . join(' ', @details);\n}\n\n# Bad: Manual argument unpacking\nsub connect_db {\n    my ($host, $port, $timeout) = @_;\n    $port    \u002F\u002F= 5432;\n    $timeout \u002F\u002F= 30;\n    # ...\n}\n```\n\n### 3. Context Sensitivity\n\nUnderstand scalar vs list context — a core Perl concept.\n\n```perl\nuse v5.36;\n\nmy @items = (1, 2, 3, 4, 5);\n\nmy @copy  = @items;            # List context: all elements\nmy $count = @items;            # Scalar context: count (5)\nsay \"Items: \" . scalar @items; # Force scalar context\n```\n\n### 4. Postfix Dereferencing\n\nUse postfix dereference syntax for readability with nested structures.\n\n```perl\nuse v5.36;\n\nmy $data = {\n    users => [\n        { name => 'Alice', roles => ['admin', 'user'] },\n        { name => 'Bob',   roles => ['user'] },\n    ],\n};\n\n# Good: Postfix dereferencing\nmy @users = $data->{users}->@*;\nmy @roles = $data->{users}[0]{roles}->@*;\nmy %first = $data->{users}[0]->%*;\n\n# Bad: Circumfix dereferencing (harder to read in chains)\nmy @users = @{ $data->{users} };\nmy @roles = @{ $data->{users}[0]{roles} };\n```\n\n### 5. The `isa` Operator (5.32+)\n\nInfix type-check — replaces `blessed($o) && $o->isa('X')`.\n\n```perl\nuse v5.36;\nif ($obj isa 'My::Class') { $obj->do_something }\n```\n\n## Error Handling\n\n### eval\u002Fdie Pattern\n\n```perl\nuse v5.36;\n\nsub parse_config($path) {\n    my $content = eval { path($path)->slurp_utf8 };\n    die \"Config error: $@\" if $@;\n    return decode_json($content);\n}\n```\n\n### Try::Tiny (Reliable Exception Handling)\n\n```perl\nuse v5.36;\nuse Try::Tiny;\n\nsub fetch_user($id) {\n    my $user = try {\n        $db->resultset('User')->find($id)\n            \u002F\u002F die \"User $id not found\\n\";\n    }\n    catch {\n        warn \"Failed to fetch user $id: $_\";\n        undef;\n    };\n    return $user;\n}\n```\n\n### Native try\u002Fcatch (5.40+)\n\n```perl\nuse v5.40;\n\nsub divide($x, $y) {\n    try {\n        die \"Division by zero\" if $y == 0;\n        return $x \u002F $y;\n    }\n    catch ($e) {\n        warn \"Error: $e\";\n        return;\n    }\n}\n```\n\n## Modern OO with Moo\n\nPrefer Moo for lightweight, modern OO. Use Moose only when its metaprotocol is needed.\n\n```perl\n# Good: Moo class\npackage User;\nuse Moo;\nuse Types::Standard qw(Str Int ArrayRef);\nuse namespace::autoclean;\n\nhas name  => (is => 'ro', isa => Str, required => 1);\nhas email => (is => 'ro', isa => Str, required => 1);\nhas age   => (is => 'ro', isa => Int, default  => sub { 0 });\nhas roles => (is => 'ro', isa => ArrayRef[Str], default => sub { [] });\n\nsub is_admin($self) {\n    return grep { $_ eq 'admin' } $self->roles->@*;\n}\n\nsub greet($self) {\n    return \"Hello, I'm \" . $self->name;\n}\n\n1;\n\n# Usage\nmy $user = User->new(\n    name  => 'Alice',\n    email => 'alice@example.com',\n    roles => ['admin', 'user'],\n);\n\n# Bad: Blessed hashref (no validation, no accessors)\npackage User;\nsub new {\n    my ($class, %args) = @_;\n    return bless \\%args, $class;\n}\nsub name { return $_[0]->{name} }\n1;\n```\n\n### Moo Roles\n\n```perl\npackage Role::Serializable;\nuse Moo::Role;\nuse JSON::MaybeXS qw(encode_json);\nrequires 'TO_HASH';\nsub to_json($self) { encode_json($self->TO_HASH) }\n1;\n\npackage User;\nuse Moo;\nwith 'Role::Serializable';\nhas name  => (is => 'ro', required => 1);\nhas email => (is => 'ro', required => 1);\nsub TO_HASH($self) { { name => $self->name, email => $self->email } }\n1;\n```\n\n### Native `class` Keyword (5.38+, Corinna)\n\n```perl\nuse v5.38;\nuse feature 'class';\nno warnings 'experimental::class';\n\nclass Point {\n    field $x :param;\n    field $y :param;\n    method magnitude() { sqrt($x**2 + $y**2) }\n}\n\nmy $p = Point->new(x => 3, y => 4);\nsay $p->magnitude;  # 5\n```\n\n## Regular Expressions\n\n### Named Captures and `\u002Fx` Flag\n\n```perl\nuse v5.36;\n\n# Good: Named captures with \u002Fx for readability\nmy $log_re = qr{\n    ^ (?\u003Ctimestamp> \\d{4}-\\d{2}-\\d{2} \\s \\d{2}:\\d{2}:\\d{2} )\n    \\s+ \\[ (?\u003Clevel> \\w+ ) \\]\n    \\s+ (?\u003Cmessage> .+ ) $\n}x;\n\nif ($line =~ $log_re) {\n    say \"Time: $+{timestamp}, Level: $+{level}\";\n    say \"Message: $+{message}\";\n}\n\n# Bad: Positional captures (hard to maintain)\nif ($line =~ \u002F^(\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2})\\s+\\[(\\w+)\\]\\s+(.+)$\u002F) {\n    say \"Time: $1, Level: $2\";\n}\n```\n\n### Precompiled Patterns\n\n```perl\nuse v5.36;\n\n# Good: Compile once, use many\nmy $email_re = qr\u002F^[A-Za-z0-9._%+-]+\\@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$\u002F;\n\nsub validate_emails(@emails) {\n    return grep { $_ =~ $email_re } @emails;\n}\n```\n\n## Data Structures\n\n### References and Safe Deep Access\n\n```perl\nuse v5.36;\n\n# Hash and array references\nmy $config = {\n    database => {\n        host => 'localhost',\n        port => 5432,\n        options => ['utf8', 'sslmode=require'],\n    },\n};\n\n# Safe deep access (returns undef if any level missing)\nmy $port = $config->{database}{port};           # 5432\nmy $missing = $config->{cache}{host};           # undef, no error\n\n# Hash slices\nmy %subset;\n@subset{qw(host port)} = @{$config->{database}}{qw(host port)};\n\n# Array slices\nmy @first_two = $config->{database}{options}->@[0, 1];\n\n# Multi-variable for loop (experimental in 5.36, stable in 5.40)\nuse feature 'for_list';\nno warnings 'experimental::for_list';\nfor my ($key, $val) (%$config) {\n    say \"$key => $val\";\n}\n```\n\n## File I\u002FO\n\n### Three-Argument Open\n\n```perl\nuse v5.36;\n\n# Good: Three-arg open with autodie (core module, eliminates 'or die')\nuse autodie;\n\nsub read_file($path) {\n    open my $fh, '\u003C:encoding(UTF-8)', $path;\n    local $\u002F;\n    my $content = \u003C$fh>;\n    close $fh;\n    return $content;\n}\n\n# Bad: Two-arg open (shell injection risk, see perl-security)\nopen FH, $path;            # NEVER do this\nopen FH, \"\u003C $path\";        # Still bad — user data in mode string\n```\n\n### Path::Tiny for File Operations\n\n```perl\nuse v5.36;\nuse Path::Tiny;\n\nmy $file = path('config', 'app.json');\nmy $content = $file->slurp_utf8;\n$file->spew_utf8($new_content);\n\n# Iterate directory\nfor my $child (path('src')->children(qr\u002F\\.pl$\u002F)) {\n    say $child->basename;\n}\n```\n\n## Module Organization\n\n### Standard Project Layout\n\n```text\nMyApp\u002F\n├── lib\u002F\n│   └── MyApp\u002F\n│       ├── App.pm           # Main module\n│       ├── Config.pm        # Configuration\n│       ├── DB.pm            # Database layer\n│       └── Util.pm          # Utilities\n├── bin\u002F\n│   └── myapp                # Entry-point script\n├── t\u002F\n│   ├── 00-load.t            # Compilation tests\n│   ├── unit\u002F                # Unit tests\n│   └── integration\u002F         # Integration tests\n├── cpanfile                 # Dependencies\n├── Makefile.PL              # Build system\n└── .perlcriticrc            # Linting config\n```\n\n### Exporter Patterns\n\n```perl\npackage MyApp::Util;\nuse v5.36;\nuse Exporter 'import';\n\nour @EXPORT_OK   = qw(trim);\nour %EXPORT_TAGS = (all => \\@EXPORT_OK);\n\nsub trim($str) { $str =~ s\u002F^\\s+|\\s+$\u002F\u002Fgr }\n\n1;\n```\n\n## Tooling\n\n### perltidy Configuration (.perltidyrc)\n\n```text\n-i=4        # 4-space indent\n-l=100      # 100-char line length\n-ci=4       # continuation indent\n-ce         # cuddled else\n-bar        # opening brace on same line\n-nolq       # don't outdent long quoted strings\n```\n\n### perlcritic Configuration (.perlcriticrc)\n\n```ini\nseverity = 3\ntheme = core + pbp + security\n\n[InputOutput::RequireCheckedSyscalls]\nfunctions = :builtins\nexclude_functions = say print\n\n[Subroutines::ProhibitExplicitReturnUndef]\nseverity = 4\n\n[ValuesAndExpressions::ProhibitMagicNumbers]\nallowed_values = 0 1 2 -1\n```\n\n### Dependency Management (cpanfile + carton)\n\n```bash\ncpanm App::cpanminus Carton   # Install tools\ncarton install                 # Install deps from cpanfile\ncarton exec -- perl bin\u002Fmyapp  # Run with local deps\n```\n\n```perl\n# cpanfile\nrequires 'Moo', '>= 2.005';\nrequires 'Path::Tiny';\nrequires 'JSON::MaybeXS';\nrequires 'Try::Tiny';\n\non test => sub {\n    requires 'Test2::V0';\n    requires 'Test::MockModule';\n};\n```\n\n## Quick Reference: Modern Perl Idioms\n\n| Legacy Pattern | Modern Replacement |\n|---|---|\n| `use strict; use warnings;` | `use v5.36;` |\n| `my ($x, $y) = @_;` | `sub foo($x, $y) { ... }` |\n| `@{ $ref }` | `$ref->@*` |\n| `%{ $ref }` | `$ref->%*` |\n| `open FH, \"\u003C $file\"` | `open my $fh, '\u003C:encoding(UTF-8)', $file` |\n| `blessed hashref` | `Moo` class with types |\n| `$1, $2, $3` | `$+{name}` (named captures) |\n| `eval { }; if ($@)` | `Try::Tiny` or native `try\u002Fcatch` (5.40+) |\n| `BEGIN { require Exporter; }` | `use Exporter 'import';` |\n| Manual file ops | `Path::Tiny` |\n| `blessed($o) && $o->isa('X')` | `$o isa 'X'` (5.32+) |\n| `builtin::true \u002F false` | `use builtin 'true', 'false';` (5.36+, experimental) |\n\n## Anti-Patterns\n\n```perl\n# 1. Two-arg open (security risk)\nopen FH, $filename;                     # NEVER\n\n# 2. Indirect object syntax (ambiguous parsing)\nmy $obj = new Foo(bar => 1);            # Bad\nmy $obj = Foo->new(bar => 1);           # Good\n\n# 3. Excessive reliance on $_\nmap { process($_) } grep { validate($_) } @items;  # Hard to follow\nmy @valid = grep { validate($_) } @items;           # Better: break it up\nmy @results = map { process($_) } @valid;\n\n# 4. Disabling strict refs\nno strict 'refs';                        # Almost always wrong\n${\"My::Package::$var\"} = $value;         # Use a hash instead\n\n# 5. Global variables as configuration\nour $TIMEOUT = 30;                       # Bad: mutable global\nuse constant TIMEOUT => 30;              # Better: constant\n# Best: Moo attribute with default\n\n# 6. String eval for module loading\neval \"require $module\";                  # Bad: code injection risk\neval \"use $module\";                      # Bad\nuse Module::Runtime 'require_module';    # Good: safe module loading\nrequire_module($module);\n```\n\n**Remember**: Modern Perl is clean, readable, and safe. Let `use v5.36` handle the boilerplate, use Moo for objects, and prefer CPAN's battle-tested modules over hand-rolled solutions.\n",{"name":5,"metadata":24,"description":7},{"origin":25},"ECC","main","5d0a87185c0e172c3901e2a6e5916b6d544b8b94","skills\u002Fperl-patterns","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance","https:\u002F\u002Fgithub.com\u002FJunMystery","AI is the typist, I am the architect. Building efficient, secure, and user-centric products through disciplined AI prompt engineering.","2026-11-13 17:41:25",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add JunMystery\u002FAgent-Guidance --skill perl-patterns",{"tool":39,"command":40},"bunx","bunx skills add JunMystery\u002FAgent-Guidance --skill perl-patterns",{"tool":42,"command":43},"pnpm","pnpm dlx skills add JunMystery\u002FAgent-Guidance --skill perl-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fperl-patterns\u002FSKILL.md",true,[],[48,54,60,66,72,78],{"skillNo":49,"name":50,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":19},"01M79QR1E309VJ6CTQKB32AWWA","zero-trust-architecture-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fzero-trust-architecture-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M79QQV7GHYR02DYGN41S23WN","xss-filter-evasion-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxss-filter-evasion-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M79QQNSN7YB8XB61FFSCS3WH","xs-leaks-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxs-leaks-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M79QQHZZJKFDY9132G5A65C2","xpath-injection-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxpath-injection-prevention-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M79QQB9ZSD3DJG8658EHQXR1","xml-security-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-security-cheat-sheet\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M79QQ60WKV7PFMXWT9CW8PM6","xml-external-entity-prevention-cheat-sheet","https:\u002F\u002Fgithub.com\u002FJunMystery\u002FAgent-Guidance\u002Fblob\u002Fmain\u002Fskills\u002Fxml-external-entity-prevention-cheat-sheet\u002FSKILL.md",[],[]]