sectokia has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I was tracking down my issue with IP's in hosts file not resolving when using AnyEvent on Windows.
I was eventually lead to this code in AnyEvent::Socket.pm:
sub _parse_hosts($) { %HOSTS = (); for (split /\n/, $_[0]) { s/#.*$//; s/^[ \t]+//; y/A-Z/a-z/; my ($addr, @aliases) = split /[ \t]+/; ...
The problem is on windows the lines in the hosts file end with '\r\n'. But this code only splits on '\n'. So whats happening is '\r' ends up literally in the (last) alias, and thus it will never match when later the attempt is made to match the hostname to the alias.
Is this a mistake in this module? Or have I somehow messed up and perl on windows? Is perl meant to treat '\n' in regex as '\r\n' when running on windows?
|
|---|