I'm cautious about making assumptions because if you can't tell that some code is obviously not Perl - while asking in a Perl forum - I cannot take anything for granted.
Anyway, it's not at all difficult to convert that code.I just doubt translating it will help you.