in reply to The complicated problem
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