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:35
RE: File::Find on WSL
Message ID:
Right that didn't work either, can't test on the filehandle. Is there a more elegant way to do this and have the warn right at the open, Uri?

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') {
    if (open my $pv, '<', '/proc/version') {
        my $lv = <$pv>;
        close $pv;
        if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1) {
            $File::Find::dont_use_nlink = 1;
    } else {
        warn "Can't open < /proc/version: $!";

The learning curve is real ...


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