Re: $File::Find and no_chdir



schms schreef:

opendir DH, $DIR or die "Cannot open '$DIR' $!";
print map "$DIR/$_\n", readdir DH;
closedir DH;

Looks very 'global variables' oriented to me.

Compare to:

{ opendir my $dh, $dir
or die "Cannot open '$dir': $!";

while (my $e = readdir $dh) {
$e = "$dir/$e";
-d $e and $e .= "/\t<--";
print "$e\n";
}
closedir $dh; # no need, is implicit
}

--
Affijn, Ruud

"Gewoon is een tijger."
.



Relevant Pages

  • Re: Newbie: Directory listing retaining symlinks
    ... Under sbcl, I achieved the goal using opendir, readdir and closedir from the sb-posix package. ... If that's not enough, you could use UFFI to define an interface to opendir, readdir, and closedir that supports more than ... (when (null-pointer-p dirp) ...
    (comp.lang.lisp)
  • Re: Deleting a folder recursively
    ... You should *ALWAYS* verify that opendir was successfull. ... closedir(). ...
    (comp.lang.perl.misc)
  • Re: readdir formulated badly? gives wrong count
    ... closedir and opendir here. ... simply correcting the typo was enough. ... So yup you hit it right. ...
    (perl.beginners)
  • Re: opendir
    ... file browser) that will be incorporated into a more specific framework, but for some incomprehensible reason, opendir will not produce correct information when called in a sub!!! ... You should probably also use lexically scoped directory ... closedir $D; ...
    (perl.beginners)
  • Re: readdir formulated badly? gives wrong count
    ... closedir and opendir here. ... Once the typeo is corrected to closedir; ... simply correcting the typo was enough. ...
    (perl.beginners)