The others appear to have helped to debug your code, but here's my suggestion: Install libnet and do it in perl.
I know you aren't the system administrator, but you can find quick and easy advice on
how to install and use modules when you aren't the admin at:
Using modules without admin privelages