in reply to regex for perl script

Personally, I don't use regexen with IP addresses. There's a node that was written in 2002 that covers some of the pitfalls that you'll encounter. See:

Don't Use Regular Expressions to Parse IP Addresses!

While using regexen for server logfiles is OK, they can turn on you.