in reply to losing files when run from /

Miscellaneous general commentary: Try something like this:
#!/usr/bin/perl -w use File::Spec::Functions qw(catfile); use strict; my @users = qw(/home/zentara); foreach $homedir (@users) { my $dh; opendir $dh, $homedir or warn "Cannot readdir $homedir:$!\n"; my @files = grep /\A[^.]/ and -f catfile($homedir, $_), readdir DIR; print "@files\n" . "#"x47 ." \n"; } exit;

File::Spec::Functions provides importable versions of File::Spec's crossplatform functions for de/constructing pathnames. These modules are in the Perl core.

Update: s/readdir DIR/readdir $dh/

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: losing files when run from /
by chanio (Priest) on Jul 27, 2005 at 19:55 UTC

      No, I wanted exactly what I wrote. What was wrong is that I had readdir DIR, which was supposed to be readdir $dh.

      Makeshifts last the longest.