solution to euler project 8, in perl