Code Snippets

Author: chris

URL Encode and Decode in Perl

Use URI::Escape for percent-encoding and decoding strings.

Author: chris

Parse CLI Arguments with Getopt::Long

Parse long and short options with type validation using Getopt::Long.

Author: chris

Connect to MySQL with DBI

Open a DBI handle to MySQL, run a SELECT, and iterate rows.

Author: chris

Parse and Encode JSON in Perl

Round-trip JSON with the JSON module: decode to a Perl hashref and re-encode.

Author: chris

HTTP GET with LWP::UserAgent

Fetch a URL with LWP::UserAgent and print the body or die on failure.

Author: chris