#!/usr/bin/perl # By Michael Kennedy, michael@toronto.com # Use or modify as you wish, but no warranty. while (<>) { if (/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/) { if ($1 <= 255 && $2 <= 255 && $3 <= 255 && $4 <= 255) { $txtip = "$1.$2.$3.$4"; $ip = pack 'C4',$1,$2,$3,$4; $hostname = (gethostbyaddr($ip,2)); $_ =~ s/$txtip/$hostname/ if ($hostname ne ""); } } print; }