#!/sw/bin/perl -w
######################
# By: Ventz Petkov   #
# Date: 8-24-05      #
# Dir/File Traversal #
######################
use strict;
use File::Find::Rule;

if (@ARGV != 1) {
    print "\t\tUsage: ./lister.pl starting_directory\n";
    print "\t\tEx: ./lister.pl /tmp\n"; exit();
}

&listdirs($ARGV[0]);

sub listdirs() {
    my $dir = shift;
    foreach my $dir (File::Find::Rule->directory->in($dir)) {
        print "$dir\n";
        opendir(DIR, $dir) or die "Can't Open $dir: $!";
        while( defined(my $file = readdir(DIR)) ) {
            unless ($file eq "." || $file eq "..") {
                my $filename = $dir."/".$file;
                print "\t$filename\n";
            }
        }
    }
}
