develooper Front page | perl.perl5.porters | Postings from December 2016

RE: File::Find on WSL

Thread Previous | Thread Next
Thorsten Behrens
December 3, 2016 22:02
RE: File::Find on WSL
Message ID:
Uri, thank you for your guidance and patience.

you are using <$lv> twice but from what i see /proc/version only outputs one line. that means your second <$lv> if executed will return undef. you need to read $lv one time into a scalar and test against that value both ways. you also are not testing the open for failure even though you know (or think you know! :), it is a linux system from $^O. trust redmond to change something in /proc/version just to mess with people. :)

How about this:

# These are hard-coded for now, but may move to hint files.
if ($^O eq 'VMS') {
    $Is_VMS = 1;
    $File::Find::dont_use_nlink  = 1;
elsif ($^O eq 'MSWin32') {
    $Is_Win32 = 1;
elsif ($^O eq 'linux') {
    open my $pv, '<', '/proc/version' or warn "Can't open < /proc/version: $!";
    if ($pv) {
        my $lv = <$pv>;
        close $pv;
        if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1) {
            $File::Find::dont_use_nlink = 1;


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About