Conversion of Holman's spark bash script to a Perl module