this has been 5 years old, but to keep it.
if any suggestions or security hole, please share them.
tree.pl
# ! /usr/bin/perl
# use strict;
# use warnings;
###########################
# same as Windows NT tree #
###########################
$dir = `pwd`;
print $dir;
$dep = 1;
&dirproc($dep);
sub dirproc {
# localize values, cz it's recursive sub-routine.
my($dep) = @_;
my(@files, $file);
# get all files in the current directry.
@files = sort(glob("*"));
# show all files in the current directry.
foreach $file (@files){
if (-f $file){
for ($i = 1; $i <= $dep; $i++){
print "|\t";
}
print $file."\n";
}
}
# show all directry in the current directry.
# if directry, calls dirproc again.
foreach $file (@files){
if(-d $file){
for ($i = 1; $i <= $dep; $i++){
print "|\t";
}
print $file."\n";
++$dep;
chdir($file);
&dirproc($dep);
chdir("..") or die "abort, maybe your environment is lack of memory.";
--$dep;
}
}
}