use Regexp::Common; s/ ( $RE{net}{IPv4} ) / $hash{$1} || $1 /xge;