ybiC has asked for the wisdom of the Perl Monks concerning the following question:
But it only processes the listed directories, not child subdirectories.
I thought I understood perlfunc:_X, push, and next. What simple silly syntax am
I doing wrong? Perl 5.00503 btw.
cheers,
Don
#!/usr/bin/perl -w use strict; my @dirs = ( # omit trailing slash '/var/www', '/home/me', '/usr/games', ); for my $dir(@dirs) { opendir DIR, $dir or warn "Error opening $dir:\n$!"; my @infiles = (readdir DIR) or warn "Error reading $dir:\n$!"; closedir DIR or warn "Error closing $dir:\n$!"; for(@infiles) { $_ =~ s/^(\.|\.\.)$//; if (-d $_) { push @dirs, $_; next; } # do stuff } } for(@dirs) { print " $_\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read directories' contents, add subdirs back into directory list
by Vynce (Friar) on Jun 02, 2001 at 10:52 UTC | |
|
Re: Read directories' contents, add subdirs back into directory list
by bikeNomad (Priest) on Jun 02, 2001 at 02:26 UTC | |
|
Re: Read directories' contents, add subdirs back into directory list
by mlong (Sexton) on Jun 02, 2001 at 02:25 UTC | |
|
(zdog) Re: Read directories' contents, add subdirs back into directory list
by zdog (Priest) on Jun 02, 2001 at 04:06 UTC | |
|
Re: Read directories' contents, add subdirs back into directory list
by Beatnik (Parson) on Jun 02, 2001 at 12:58 UTC | |
|
Re: Read directories' contents, add subdirs back into directory list
by clintp (Curate) on Jun 02, 2001 at 17:43 UTC |