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: Directory reading
    ... As proposed by others, the functions opendir(), readdir() and ... closedir() are the way to read a directory under Linux/UNIX/Bsd. ...
    (comp.lang.c)
  • Re: String searching in a FILE*
    ... opendir(), readdir(), and closedir() than to use popen, fread(), and pclose. ...
    (comp.lang.c)
  • Re: Directory reading
    ... As proposed by others, the functions opendir(), readdir() and ... closedir() are the way to read a directory under Linux/UNIX/Bsd. ...
    (comp.lang.c)
  • 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)