Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

perl

/perl

Pomaga w pracy z Perlem: wyrażenia regularne, hasze, moduły CPAN i przetwarzanie tekstu, w utrzymaniu starych skryptów i narzędzi administracyjnych.

Repozytorium
Agent-Skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
01.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 01.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pomaga w pracy z Perlem: wyrażenia regularne, hasze, moduły CPAN i przetwarzanie tekstu, w utrzymaniu starych skryptów i narzędzi administracyjnych.

Oryginalny opis (EN)

Expert Perl assistance covering regular expressions, hashes, CPAN modules, and text processing. Use when maintaining legacy Perl scripts, performing complex regex manipulations, or writing sysadmin tools.

Jak działa

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Sekcje z nagłówków SKILL.md, w oryginale · 135 linii, 601 słów
Podgląd SKILL.md
---
name: perl
description: Expert Perl assistance covering regular expressions, hashes, CPAN modules, and text processing. Use when maintaining legacy Perl scripts, performing complex regex manipulations, or writing sysadmin tools.
---

# Perl

Perl is a highly capable, feature-rich programming language renowned for powerful regular expression processing, system administration automation, and robust text transformation.

## When to Use

- **Text Processing & Regex Data Extraction**: Rapidly parsing unstructured log files, reports, and legacy data streams.
- **Legacy System Administration & DevOps**: Maintaining established Unix/Linux automation scripts and cron jobs.
- **Bioinformatics & Scientific Data Wrangling**: Processing genomic sequencing data and legacy scientific FASTA records.
- **Maintaining Classic CPAN Applications**: Supporting production enterprise backends built on Catalyst, Mojolicious, or Dancer.

## Quick Start

```perl
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';

my %scores = ( Alice => 95, Bob => 88, Charlie => 92 );

for my $name (sort keys %scores) {
    say "$name scored $scores{$name}";
}
```

## Core Concepts

### Regular Expressions as First-Class Language Primitives

Perl regular expressions are deeply integrated into language syntax:

```perl
use strict;
use warnings;
use v5.36;

my $log_entry = '[2026-09-27 10:15:30] ERROR: Payment gateway timeout (code 504)';

if ($log_entry =~ /\[(.*?)\]\s+(\w+):\s+(.*)/) {
    my ($timestamp, $severity, $message) = ($1, $2, $3);
    say "Timestamp: $timestamp";
    say "Severity:  $severity";
    say "Message:   $message";
}
```

### Modern Perl (v5.36+ / v5.38+) Native Subroutine Signatures

Replaces manual `@_` unpacking with native typed signatures and experimental class features:

```perl
use v5.38;
use experimental 'class';

class Account {
    field $balance :param = 0;

    method deposit($amount) {
        $balance += $amount;
        return $balance;
    }

    method get_balance() { return $balance; }
}

my $acc = Account->new(balance => 100);
$acc->deposit(50);
say "Balance: ", $acc->get_balance(); # 150
```

### Context Awareness (Scalar vs List Context)

Functions dynamically change return values based on whether a scalar or list is expected:

```perl
my @items = ("apple", "banana", "cherry");
my $count = @items;     # Scalar context returns array count: 3
my ($first) = @items;   # List context returns first element: "apple"
```

## Common Patterns

### Robust File Parsing with Regular Expressions

**Problem**: Extracting structured fields from inconsistent log files.

**Solution**:
Use strict mode with named regex capture groups:

```perl
use strict;
use warnings;
use feature 'say';

while (my $line = <DATA>) {
    chomp $line;
    if ($line =~ /^\[(?<timestamp>[^\]]+)\]\s+(?<level>INFO|WARN|ERROR)\s+(?<msg>.*)$/) {
        say "Time: $+{timestamp} | Level: $+{level} | Message: $+{msg}";
    }
}

__DATA__
[2025-03-01 12:00:00] INFO Server started successfully
[2025-03-01 12:01:23] ERROR Database connection failed
```

## Best Practices

**Do**:

- Always Declare `use strict; use warnings;`: Eliminate dangerous silent global variables and undeclared lexical bugs.
- Use `use v5.36;` or Higher: Automatically enables strict, warnings, modern subroutine signatures, and say syntax.
- Use Mojolicious for Web APIs: Build modern non-blocking web backends and WebSockets with Mojolicious.
- Manage Dependencies with `cpanm` and `Carton`: Isolate project dependencies locally in `local/` rather than modifying system Perl.

**Don't**:

- Use single-character global punctuation variables: Replace `$@`, `$/`, and `$_` with readable `English` module aliases or modern signatures.
- Use two-argument `open`: Always use 3-argument open (`open(my $fh, "<", $filename)`) with lexical filehandles.
- Write new OO code with bare blessed hashes: Use modern `use v5.38; use experimental 'class';` or `Moo`/`Moose`.

## Troubleshooting

| Error                                                | Cause                                                                   | Solution                                                           |
| :--------------------------------------------------- | :---------------------------------------------------------------------- | :----------------------------------------------------------------- |
| `Global symbol "..." requires explicit package name` | Variable used without prior `my`, `our`, or `state` under `use strict`. | Declare variable with `my $var`.                                   |
| `Can't locate ... in @INC`                           | Required CPAN module not installed in Perl lib path.                    | Install module using `cpanm Module::Name`.                         |
| `Modification of a read-only value attempted`        | Attempting to modify constant or `$_` aliased to literal string.        | Assign to local mutable variable `my $copy = $_` before modifying. |

## References

- [Perl.org](https://www.perl.org/)

Wersje

RepozytoriumWynikLicencja
Ta strona · G1Joshi/Agent-Skills100MIT
dkbnull/hello-skill86MIT

Migawka bazy z 13.11.2026 · wersja paczki 9d0615dff1df (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100cpan-release
    Ocenia błędy w raportach CPAN Testers i Magpie oraz przygotowuje kolejne wydanie dystrybucji Perl: sprawdza, co naprawdę jest na CPAN, odtwarza błąd i pisze wpis w Changes.
  • 100perl-review
    Przegląda kod Perla (.pm, .pl, .t) na gałęzi pod kątem standardów projektu, także po napisaniu lub zmianie kodu.
  • 100perl-patterns
    Podaje nowoczesne idiomy i konwencje Perla 5.36+, by pisać czytelny i łatwy w utrzymaniu kod.
  • 100perl-patterns
    Stosuje nowoczesne idiomy i konwencje Perla 5.36+ przy pisaniu oraz przeglądzie trwałych i łatwych w utrzymaniu aplikacji.
  • 95tune-perl-ci
    Modernizuje i utwardza CI w GitHub Actions dla projektu Perl, np. workflow z perl-tester albo instalatorami cpm i cpanm.
  • 100perl-testing
    Pomaga pisać testy w Perlu z Test2::V0 i Test::More, uruchamiać je przez prove, mockować i mierzyć pokrycie Devel::Cover.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.