Skip to content

Commit

Permalink
Replace bareword filehandle with a lexical scalar:
Browse files Browse the repository at this point in the history
Bareword filehandles are bad and this module should really remove
this one.

I'm also bumping the version to a stable one because why not.
  • Loading branch information
xsawyerx committed Dec 28, 2021
1 parent 4713e38 commit a808377
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ext/File-Find/lib/File/Find.pm
Expand Up @@ -3,7 +3,7 @@ use 5.006;
use strict;
use warnings;
use warnings::register;
our $VERSION = '1.39_01';
our $VERSION = '1.40';
use Exporter 'import';
require Cwd;

Expand Down Expand Up @@ -322,7 +322,7 @@ sub _find_dir($$$) {
$dir_pref= ( $p_dir eq '/' ? '/' : "$p_dir/" );
}

local ($dir, $name, $prune, *DIR);
local ($dir, $name, $prune);

unless ( $no_chdir || ($p_dir eq $File::Find::current_dir)) {
my $udir = $p_dir;
Expand Down Expand Up @@ -381,12 +381,13 @@ sub _find_dir($$$) {
$dir= $dir_name; # $File::Find::dir

# Get the list of files in the current directory.
unless (opendir DIR, ($no_chdir ? $dir_name : $File::Find::current_dir)) {
my $dh;
unless (opendir $dh, ($no_chdir ? $dir_name : $File::Find::current_dir)) {
warnings::warnif "Can't opendir($dir_name): $!\n";
next;
}
@filenames = readdir DIR;
closedir(DIR);
@filenames = readdir $dh;
closedir($dh);
@filenames = $pre_process->(@filenames) if $pre_process;
push @Stack,[$CdLvl,$dir_name,"",-2] if $post_process;

Expand Down Expand Up @@ -542,7 +543,7 @@ sub _find_dir_symlnk($$$) {
$dir_pref = ( $p_dir eq '/' ? '/' : "$p_dir/" );
$loc_pref = ( $dir_loc eq '/' ? '/' : "$dir_loc/" );

local ($dir, $name, $fullname, $prune, *DIR);
local ($dir, $name, $fullname, $prune);

unless ($no_chdir) {
# untaint the topdir
Expand Down Expand Up @@ -614,12 +615,13 @@ sub _find_dir_symlnk($$$) {
$dir = $dir_name; # $File::Find::dir

# Get the list of files in the current directory.
unless (opendir DIR, ($no_chdir ? $dir_loc : $File::Find::current_dir)) {
my $dh;
unless (opendir $dh, ($no_chdir ? $dir_loc : $File::Find::current_dir)) {
warnings::warnif "Can't opendir($dir_loc): $!\n";
next;
}
@filenames = readdir DIR;
closedir(DIR);
@filenames = readdir $dh;
closedir($dh);

for my $FN (@filenames) {
if ($Is_VMS) {
Expand Down

0 comments on commit a808377

Please sign in to comment.