On 07/06/2007 04:46 PM, Chris Ryan wrote:
yitzle wrote:
1) There are filesystem modules already out there.
2) You might want to consider using a more generic recursive structure.

3) To answer your question, check its a directory and not a file.

while ($yearly = readdir(TOTALHANDLE)) {
next unless (-d $yearly);


I understand the -next- concept, but adding this line made no
difference.  I got the same output as without it.

--Chris


I suggest you make it more organized and don't constantly change directories:

use warnings;
use File::Spec::Functions;
use Fatal qw/opendir closedir/;
exit;

my $dir = "/whatever/";

opendir TOTALHANDLE, $dir;
while (my $yearly = readdir(TOTALHANDLE)) {
    my $path = catdir($dir, $yearly);
    next unless -d $path;

    opendir YH, $path;
    while (my $monthly = readdir($path)) {
        my $path = catdir($path, $monthly);
        print $path, "\n";
    }
    closedir YH;
}
closedir TOTALHANDLE;

__END__

I don't have a suitable directory structure available, so I exit at the start.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to