in reply to What's the bug ?

Imagine you wrote the following:

#!/usr/local/bin/perl print $message;

$message is undefined, so print will output nothing. If you use the strict pragma, it will complain alert you that you forgot to define $message.

The same thing is happening in your program. You try to do something with $ip before you have declared it. In this case, you need to instantiate $ip as a Net::IP object as suggested by tcf22.