Kautilya has asked for the wisdom of the Perl Monks concerning the following question:

How do I traverse the directory and find the files in the diectory and at the same time go reccursively down and search for the subdirectory as well.

I tried following code to print the file names but it gives error.

use IO::ALL $some_dir = "/cygdrive/e/Uns-Root/Sev"; $dir = io($some_dir); while (my $io = $dir->read) { print $io->name, "\n" if $io->is_file; }
Error is
Can't locate IO/ALL.pm in @INC (@INC contains: C:/Perl/lib C:/Perl/sit +e/lib .) at e:\Uns-Root\DirStru.pl line 4. BEGIN failed--compilation aborted at e:\Uns-Root\DirStru.pl line 4.

Replies are listed 'Best First'.
Re: Direcctory Traversal
by Corion (Patriarch) on Sep 22, 2005 at 16:47 UTC
Re: Direcctory Traversal
by sk (Curate) on Sep 22, 2005 at 17:20 UTC
    Is there a particular reason why you did not do something like this?

    use strict; use warnings; use File::Find; my $dir= '/some/directory'; finddepth(\&printme, $dir); sub printme { print $File::Find::name,$/; }
Re: Direcctory Traversal
by marto (Cardinal) on Sep 22, 2005 at 16:27 UTC
Re: Direcctory Traversal
by radiantmatrix (Parson) on Sep 22, 2005 at 19:27 UTC

    You are receiving this error because the module IO:All is not installed (and because you are referencing it in all upper-case, rather than with the correct mixed-case -- this is important).

    However, please have a look at File::Find. IO::All is probably not what you want. File::Find is explicitly intended to find files and directories recursively.

    <-radiant.matrix->
    Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
    The Code that can be seen is not the true Code
    "In any sufficiently large group of people, most are idiots" - Kaa's Law