Perl Examples

PerlOct 23, 2026

Perl aligned plain-text terminal table

Renders rows as a padded plain-text terminal table sized to the widest cell in every column.

formattingtableterminalcli
000
PerlOct 23, 2026

Perl base64 encode and decode with checks

Encodes bytes to base64 and decodes them back, rejecting bad lengths, characters, and padding.

encodingbinarybase64
000
PerlOct 23, 2026

Perl field-level input validation errors

Validates user input against simple rules and returns per-field error messages for a form.

errorsvalidationforms
000
PerlOct 23, 2026

Perl build and parse URL query strings

Encodes a hash into a URL query string and parses one back, keeping repeated keys as arrays.

query-stringurlencoding
000
PerlOct 23, 2026

Perl bounded worker pool over a queue

Runs a fixed number of worker threads over a shared job queue and collects results with errors.

concurrencyqueueworkers
000
PerlOct 23, 2026

Perl JSON decode with positioned errors

Decodes JSON text and reports the byte offset of the first syntax error instead of a vague failure.

parsingerrorsjson
000
PerlOct 23, 2026

Perl HTTP GET JSON with alarm timeout

Fetches JSON over HTTP with a hard connection timeout and decodes the response body safely.

httpnetworkjsontimeout
000
PerlOct 23, 2026

Perl environment config with validation

Reads environment variables with defaults, required checks, and integer coercion into a config hash.

environmentconfigurationvalidation
000
PerlOct 23, 2026

Perl token bucket rate limiter

Allows short bursts above the average rate while enforcing a steady long-term token refill.

token-bucketthrottlerate-limiting
000
PerlOct 23, 2026

Perl bounded LRU cache with hash and list

Keeps frequently used entries in a size-bounded cache and evicts the least recently used one.

lrucachememory
000
PerlOct 23, 2026

Perl multi-key stable sort with nulls

Sorts records by several keys in priority order, placing undefined values last for each key.

stablesortingrecordscomparator
000
PerlOct 23, 2026

Perl split a list into fixed-size chunks

Splits any list into consecutive batches of a fixed size, with a shorter final batch when needed.

batchingarraysiteration
000
PerlOct 23, 2026

Perl stream file lines with line numbers

Reads a text file one line at a time without slurping it, passing each line to a callback.

streaminglinesfile-io
000
PerlOct 23, 2026

Perl deep clone and recursive hash merge

Deep-copies nested hash and array structures, then merges two configs without sharing references.

mergerecursiondata-structuresclone
000
PerlOct 23, 2026

Perl capped exponential backoff with jitter

Retries a code block with capped exponential backoff plus randomized jitter between attempts.

resiliencebackoffretryjitter
000