in reply to Re: Strawberry Perl: Windows hosts file not working?
in thread Strawberry Perl: Windows hosts file not working?

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.

I couldn't get your example to work on Windows 7 with Strawberry Perl-5.32.0:
C:\etc>type hosts 127.0.0.1 www.google.com.au C:\etc>perl -MSocket -wle "my $pip=gethostbyname('www.google.com.au'); +my $ip=inet_ntoa($pip);print $ip;" 142.250.66.195
Maybe the hosts file needs to be elsewhere and/or named something else. (I also made a copy of etc/hosts named etc/hosts.txt.)

Sorry ... I don't have much knowledge on this sort of stuff ... just reporting what I found.

Cheers,
Rob

Replies are listed 'Best First'.
Re^3: Strawberry Perl: Windows hosts file not working?
by LanX (Saint) on Feb 14, 2022 at 01:02 UTC
    For such things I used C:\Windows\System32\drivers\etc\hosts in the past.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      For such things I used C:\Windows\System32\drivers\etc\hosts in the past

      Aaah, yes - that looks right. (The file already exists.)
      Sorry for the noise.

      Cheers,
      Rob