Code fragments from my blog at http://perlpearls.jimmetzger.net/