I can vouch that gethostbyname will use the hosts file on Linux.
This one-liner resolves a hostname to an IPv4 address:
perl -w -MSocket -e 'my $pip=gethostbyname("www.google.com");my $ip=in +et_ntoa($pip);print $ip,"\n";'
"Normal" resolution via DNS returns: 142.250.72.132
If I add this line to /etc/hosts:127.0.0.1 www.google.com
The above one-liner returns: 127.0.0.1
So on Linux, Perl will use the hosts file (Well, technically, it use the resolver library). However, I don't have a Windows machine with Perl handy to test with so I do not know if it will also work there. No good reason it shouldn't.
In reply to Re: Strawberry Perl: Windows hosts file not working?
by enemyofthestate
in thread Strawberry Perl: Windows hosts file not working?
by sectokia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |