Explain Perl code
Paste Perl and Vibe explains what each regular expression captures, whether a sigil means one value, a list or a hash, and what a sort block compares.
Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.
Vibe25 lines selected
Press Explain it for the sample, or paste your own code first.
What this Perl sample shows
- scalars, arrays and hashes
- The first character says what a variable holds:
$lineis one value,@slowesta list and%hitsa hash of keys and values. One entry of a hash is a single value, so it takes$:$hits{$path}. The first time a path turns up its entry is empty, and++starts it from 0. - regular expressions
m{...}is a match written with braces in place of slashes, which helps when the text has/in it. Each pair of brackets captures one part into$1to$4: the method, the path, the 3-digit status and the milliseconds.next unlessskips a line that doesn't match, so the sample log'shealth check okline is ignored.- strict and warnings
use strictmakes every variable be declared withmy. Without it, a typo such as$hit{...}for$hits{...}quietly made a second hash and the count came out as0 paths. With it, Perl refused to run and named%hit.- sort with a comparison
sort { ... } keys %hitsorders the paths using the block, where$aand$bare the two being compared.<=>compares numbers, and putting$bon the left sorts largest first, here by average time.@slowest[0 .. 2]takes the first three, andlast unless defined $pathstops early when the log has fewer pages.
Good to know
- Run with Perl 5.42.2 on a 9-line sample log, the script printed
/api/signupat 925 ms average over 2 requests,/pricingat 396 ms and/docsat 92 ms, then1 server errorsfor the one 503. <>reads the files named on the command line a line at a time, or standard input when there are none, socat access.log | perl slow_pages.plprinted the same result.- With only two pages in the log, the script printed both and stopped with no warning, because of the
definedcheck.
Watch out: == compares numbers and eq compares text. "GET" == "POST" came out true: Perl turned both words into 0, printed Argument "POST" isn't numeric in numeric eq (==) and carried on. A log saved on Windows has a hidden \r at the end of each line, so ms$ never matched and the script printed only 0 server errors, with no error. Adding $line =~ s/\r$//; as the loop's first line fixed it.
Explain Perl code beside your editor
Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).
Install on Mac
curl -fsSL https://unvibe.site/install.sh | bashPaste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.
Or download the .dmg · Intel Mac build · SHA-256 checksums
Opening the .dmg the first time
- Open the .dmg and drag Unvibe to Applications.
- Open it once; macOS says it can't verify it. Click Done.

Real screen, macOS 15 - System Settings › Privacy & Security › Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.

Real screen, macOS 15
The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open