Tweaked Perl script to run on Imperial cluster