Intrepid has asked for the wisdom of the Perl Monks concerning the following question:

I am posting a success instead of a failure, for a change ;-). In brief, I've patched the test file for Win32::Netsh so that the Wlan instance tests no longer fail (on a recent Windows release). I first wrote a short subroutine which I'll submit here for comments and critiques:

#!/usr/bin/env perl use strict; use v5.18; use utf8; use warnings; use Carp qw/carp croak/; =head1 DESCRIPTION Find the major Windows version from the commandline "ver" command. =cut # ------------------------------------------------------- # # Example Windows 11 version string (bought the machine # with Windows 10 loaded on it): # Microsoft Windows [Version 10.0.26100.4349] # ------------------------------------------------------- # sub findVer { my ( $which , $verstr ); $verstr = `ver`; chomp $verstr; $verstr =~s{\A\n}{}; $verstr =~m'\[Version\s (\d+) [.]'x; carp( qq/Couldn't get version from string "$verstr"/ ) unless $1; $which = $1; return $which; } say findVer(); __END__

The reason it matters to Win32::Netsh is that at some vague point in time (Google AI doesn't know exactly when), M$ stopped calling a wireless interface a "Wireless Network Connection" and started calling it a "Wi-Fi". This broke the Win32::Netsh test suite file 02-Win32-Netsh-Wlan.t for my machine. Here's the patch (Unified diff format, line endings converted to UNIX). I'd be very interested in hearing from other Windows Perlers how this patch works on their version of Windows (I'm going to test it on Windows7):

--- a/t/02-Win32-Netsh-Wlan.t 2015-11-17 16:07:55.000000000 -0500 +++ b/t/02-Win32-Netsh-Wlan.t 2025-06-18 14:52:56.388437700 -0400 @@ -26,36 +26,61 @@ ); } use_ok(qq{Win32::Netsh::Wlan}, (qw(:all))); } +##--------------------------------------- +## Find Windows Version + +# ------------------------------------------------------- # +# Example Windows 11? or 10? version string: +# Microsoft Windows [Version 10.0.26100.4349] +# ------------------------------------------------------- # +sub findVer +{ + my ( $which , $verstr ); + $verstr = `ver`; + chomp $verstr; + $verstr =~s{\A\n}{}; + $verstr =~m'\[Version\s (\d+) [.]'x; + carp( qq/Couldn't get Windows version from string "$verstr"/ ) un +less $1; + $which = $1; + # say "VERSION: " . $which; + return $which; +} + +my $generation = findVer(); ##--------------------------------------- ## List of profiles to use for testing ##--------------------------------------- my @test_profiles = ( { filename => qq{win32-netsh-wlan-single.xml}, info => { name => qq{Win32-Netsh-Wlan-Single}, auth => qq{Open}, cipher => qq{None}, - interface => qq{Wireless Network Connection}, + interface => ( $generation >= 10 ? + qq{Wi-Fi} + : qq{Wireless Network Connection} ), mode => qq{automatical}, net_type => qq{Infrastructure}, radio => qq{[ Any Radio Type ]}, ssid => [qq{SSID-Single}], }, }, { filename => qq{win32-netsh-wlan-dual.xml}, info => { name => qq{Win32-Netsh-Wlan-Dual}, auth => qq{Open}, cipher => qq{None}, - interface => qq{Wireless Network Connection}, + interface => ( $generation >= 10 ? + qq{Wi-Fi} + : qq{Wireless Network Connection} ), mode => qq{automatical}, net_type => qq{Infrastructure}, radio => qq{[ Any Radio Type ]}, ssid => [ qq{SSID-Dual-01}, qq{SSID-Dual-02}
Jun 18, 2025 at 20:50 UTC

Replies are listed 'Best First'.
Re: Win32::Netsh tests repaired (-:
by InfiniteSilence (Curate) on Jun 22, 2025 at 03:39 UTC

    Professionalism...I think when it comes to certain companies we need to take a step back and decide whether to take the red pill or the blue one.

    When I was in college Microsoft was computing. I tried hard to ignore what the free software community was talking about until I started running into problems. I wanted the freedom to share software with whomever I wanted and a for-profit company beholden to shareholders saw things differently. Oh, I tried to ride the fence with Cygwin, Perls like Strawberry, etc. But eventually I realized that it wasn't worth it and made the switch to Linux unless I absolutely had to use Windows. And in those cases I was not an enthusiastic participant.

    So I don't agree that anybody here on Perlmonks should be chided for pointing out that Microsoft has not been friendly to the free/open-source community and the FSF has as recently as December of last year asked for continued pressure to be placed on them for their activities.

    That, to me, is professionalism.

    Celebrate Intellectual Diversity

Re: Win32::Netsh tests repaired (-:
by Intrepid (Curate) on Jun 23, 2025 at 00:44 UTC

    I'm replying to myself as I indicated I would, now that I've tested the modified test file in the Win32::Netsh package on a different version of Windows. It took several sessions of reacquainting myself with the Perl installations on a 11-year old (at least) laptop I'd set aside to gather dust. I have StrawberryPerl v5.12.1 on that laptop.

    Once I was done stumbling around in CygwinPerl instead of working in Strawberry (-;, I ran a make test first with the package as downloaded, that is, with no patches applied to 02-Win32-Netsh-Wlan.t, then did it again with that test file patched. The visible result was the same; the tests passed in each case. This proves that Windows 7 uses the old Wireless Network Connection terminology in its netsh output. And demonstrates that my patch won't break things if someone is installing to an old Windows system.

      Soren

    Jun 23, 2025 at 00:44 UTC

    A just machine to make big decisions
    Programmed by fellows (and gals) with compassion and vision
    We'll be clean when their work is done
    We'll be eternally free yes, and eternally young
    Donald Fagen —> I.G.Y.
    (Slightly modified for inclusiveness)

Re: Win32::Netsh tests repaired (-:
by stevieb (Canon) on Jun 19, 2025 at 08:03 UTC

    Patch appears sane at a glance. I'll try to test tomorrow. Hopefully others who use Windows will do so first. Just a note... to me, you come off as someone who lacks professionalism when you say things like "M$". Don't do that. Say Microsoft. Hold up professional integrity, despite any emotional feelings you have.

    You will not impress anyone here by being childish, or by trying to be immature. Always stand by proper corporate names when referencing a company no matter how you personally feel.

    -stevieb

      You will not impress anyone here by being childish, or by trying to be immature. ... Say Microsoft. Hold up professional integrity

      Valid comment. Point taken; I'll try to avoid such habitual quirks in the future.

        Soren