ruby translation of original harvester perl script