ok got it done. i didnt use tree because im trying to avoid using cpan for this project. heres the code if someones interested:
#!/usr/bin/perl
($dir) = @ARGV;
open (MYFILE, '>>data.txt') || die;
&loopDir($dir, "");
exit;
sub loopDir {
$dir = "." unless $dir;
local($dir, $margin) = @_;
chdir($dir) || die "Cannot chdir to $dir\n";
local(*DIR);
opendir(DIR, ".");
while ($f=readdir(DIR)) {
next if ($f eq "." || $f eq "..");
print MYFILE "$margin$f\n";
if (-d $f) {
&loopDir($f,$margin." ");
}
}
closedir(DIR);
chdir("..");
}
close (MYFILE);
|