Your /etc/hosts file lines 3 and 11 have zero or more white space characters and nothing else. You should skip those:
while (<FILE>) { next if /\A\s*\z/ ; # skip blank lines next if /^\s*#/ ; # skip comments
Or combine the regexes:
next if /\A\s*(?:#|\z)/ ; skip comments and blank lines
In reply to Re^3: How To Read Hosts File Into a Hash
by keszler
in thread How To Read Hosts File Into a Hash
by at2marty
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |