in reply to Re^2: parsing a terrible /etc/hosts
in thread parsing a terrible /etc/hosts
Config::Hosts Interface to /etc/hosts file
As far as i remember(AIX, ubuntu, win) you may have duplicate lines with the same ip and they are "joined".if ($hosts->{$ip}) { print STDERR "Line $l: Warning: duplicate IP entry $ip, the last one + will be used\n"; }
it makes the host-name 192.168.0.1 map to the ip of 127.0.0.1, common use is by script kiddies tho.127.0.0.1 192.168.0.1
Parse::Hosts Parse /etc/hosts
only reads /etc/hosts or you have to read it yourself and pass it in. "output" is an array of hashs {ip => $ip, hosts => \@hosts}unless (defined $content) { open my($fh), "<", "/etc/hosts" or return [500, "Can't read /etc/hosts: $!"]; local $/; $content = <$fh>; }
App::ParseHosts Parse /etc/hosts (CLI) Just a wrapper around Parse::Hosts to allow you to read anyfile
Mine parses the lines same way as them, and has more usable data structures for the task and example. Mine doesnt check for valid ipv4 or ipv6 format tho like Config::Hosts almost does. I looked at Config::Hosts first and didnt like it
add: and none are core either
|
|---|