[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M70GMXG5YYYR7WXH3MRDGDM8":3,"skill-same:01M70GMXG5YYYR7WXH3MRDGDM8":65},{"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":23,"publishedAt":36,"linkOnly":37,"markdownContent":38,"markdownBody":39,"frontMatter":40,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":46,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M70GMXG5YYYR7WXH3MRDGDM8","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.","mdnaimul22\u002Fhuman-skills","mdnaimul22","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F64520358?v=4","01M70FH95MH2H796Q01TYSFZ03","Naimul","01M70FH96798CQR4YHA13F17GA",3,"MIT","https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fstorage\u002Faffaan-m_ECC\u002Fperl-patterns\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[24,25,26,27,28,29,30,31,32,33,34,35],"perl patterns","patterns","perl","writing","when","code","for","applications","use","best practices","conventions","idioms","2026-11-10 10:12:30",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":41,"description":7},{"origin":42},"ECC","main","74715deacdc69119d739f38916f8ee4f0f979ebf","skills\u002Fstorage\u002Faffaan-m_ECC\u002Fperl-patterns",0,"https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills","https:\u002F\u002Fgithub.com\u002Fmdnaimul22","AI Agents Workflows Automation | Specializing in Python, FastAPI, MCP Agents & Custom ERP.","2026-11-11 21:16:57",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add mdnaimul22\u002Fhuman-skills --skill perl-patterns",{"tool":57,"command":58},"bunx","bunx skills add mdnaimul22\u002Fhuman-skills --skill perl-patterns",{"tool":60,"command":61},"pnpm","pnpm dlx skills add mdnaimul22\u002Fhuman-skills --skill perl-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fstorage\u002Faffaan-m_ECC\u002Fperl-patterns\u002FSKILL.md",true,[],[66,74,82,89,96,103],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":73},"01M767791C1KRP2ZRW2Z73VZ5Q","system-lifecycle-designer","Universal architectural methodology for designing granular, atomic, and sub-atomic lifecycles and end-to-end workflows for single functionality integrations across any domain (daemons, batch jobs, request transactions, resource pools). Provides patterns for deterministic identity, pre-commit validation, differential reconciliation, sticky leasing, state machines, transactional persistence, and closed-loop feedback.","https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fstorage\u002Fmy_skills\u002Fsystem-lifecycle-designer\u002FSKILL.md",[],[],"2026-11-12 13:55:43",{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":81},"01M748ABPN5F1FANHH6HKZQMXT","style-sampling","Make a new episode in a proven video style - Collage Explainer, Finance Explainer, Animated Science Explainer, 3D Brand Explainer, 3D True Crime - on the person's topic. Use for \"an episode of\", \"in the style of\", \"sample this style\", 「用这个风格做一集」. One video to copy is reverse-any-video.","https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fstorage\u002Fheygen-com_hyperframes\u002Fstyle-sampling\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":81},"01M748A59V04PKW4HA0XQ81FGP","reverse-any-video","Rebuild any video file as an editable HyperFrames project - motion graphics, talking heads, live action or AI-generated footage - checked against the original frame by frame. Use to reverse, recreate, remake, replicate or copy a video, or 「复刻这个视频」「照着这个视频做一个」.","https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fstorage\u002Fheygen-com_hyperframes\u002Freverse-any-video\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":81},"01M7487T50P55CSXMWXZ0G9KRG","typescript-patterns","TypeScript patterns for strict, type-safe, maintainable code in modern TypeScript and JavaScript applications. Covers strict compiler configuration, type design, narrowing, discriminated unions, generics, async and error handling, module boundaries, dependency hygiene, and type-level testing. Use when writing or reviewing TypeScript or JavaScript code.","https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fstorage\u002Faffaan-m_ECC\u002Ftypescript-patterns\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":81},"01M7487ERZRGPC5NJ75077Y238","test-collaboration","Inventory and govern a project's test assets. Connect requirements, business rules, risks, bugs, and cross-boundary contracts to stable TEST-IDs and executable evidence in the repository's existing test registry or TESTS.md. Use for test inventory, test gap analysis, unit\u002Fintegration\u002Fcontract\u002FE2E\u002Fsmoke classification, bug-to-test regression protection, consumer\u002Fprovider contract testing, test-necessity review, and pre-delivery evidence review.","https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fstorage\u002Faffaan-m_ECC\u002Ftest-collaboration\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":81},"01M748721J3GKR2WS6K0QWFC35","story-lifecycle","Manage a file-based epic → story → sprint development loop without requiring an external project management tool. Creates and tracks epics, breaks them into user stories, assigns them to sprints, and drives implementation story by story. Use when starting a new feature initiative or when the team has no Jira\u002FLinear\u002FTaiga but needs structured delivery tracking.","https:\u002F\u002Fgithub.com\u002Fmdnaimul22\u002Fhuman-skills\u002Fblob\u002Fmain\u002Fskills\u002Fstorage\u002Faffaan-m_ECC\u002Fstory-lifecycle\u002FSKILL.md",[],[]]