in reply to can anyone help to detect any error in this script

Please use <code> tags around your code - it's not readable without, as you might be able to see...

Update: Now that the <code> tags are added, it seems that you should have the quotes around the hostname too in the $hostname variable. Please try to die with $hostname and not $server to see what you really have in that variable. I don't know what exactly the inet_aton function does if it gets bogus input, but that might be the problem.
use signature; signature(" So long\nAlfie");