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

Re: File::Find on WSL

Thread Previous | Thread Next
From:
Uri Guttman
Date:
December 4, 2016 04:13
Subject:
Re: File::Find on WSL
Message ID:
584397C1.1060006@stemsystems.com
On 12/03/2016 05:02 PM, Thorsten Behrens wrote:
>
> # 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: $!";
>
do you want that to be a warn or a die? i would call die as that means 
the $^O is misleading or something made /proc/version disappear. a 
warning does little good there as the typical caller of file::find won't 
understand what is wrong.
>
>     if ($pv) {
>
and if you die, then you don't need to check if $pv is true. simpler 
that way.
>
>         my $lv = <$pv>;
>
>         close $pv;
>
no need to explicitly close $pv as it is declared in a tight scope and 
will be closed upon scope exit.

uri


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About