perl -pi -e 'BEGIN{ local @ARGV = ("IP_addr.txt"); %IP = map {$_ => 1;} <>; } $_ = "#" . $_ if /((\d{1,3}\.){3}(\d{1,3}))/ and exists $IP{$1};'