in reply to The complicated problem

Simple -- It's a Three Step Process:

First: change the first line of your code from #!/usr/bin/perl to #!/usr/bin/php

Second: correct all the errors.

Third: ....

----
I Go Back to Sleep, Now.

OGB