#!/usr/bin/perl $nBottles = abs(shift || 100); $p_sub = sub { 'Take ' . (shift == 1 ? 'it' : 'one') . " down, pass it around,\n" }; $b_sub = sub { 'bottle' . (shift != 1 ? 's' : '') }; $c_sub = sub { $_ = shift||'No'; "$_ " . &$b_sub($_) . ' of beer' }; $w_sub = sub { &$c_sub(shift) . " on the wall"; }; $sub = sub { $_ = shift; print &$w_sub($_), ",\n", &$c_sub($_), ",\n", &$p_sub($_), &$w_sub(--$_), ".\n\n" }; map(&$sub($_), reverse(1 .. $nBottles)); print "burp!\n";