Code Snippets

Language: Perl

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

Write Lines to a File in Perl

Open a file for writing and emit several lines, then close cleanly.

Author: chris

Read a File Line by Line in Perl

Open a filehandle and iterate over a text file one line at a time, chomping trailing newlines.

Author: chris