Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (25 sloc) 0.495 kb
#!/usr/bin/perl
=head1 NAME
tree.pl - print a directory tree
=cut
## by rjbs
## origin: written for phun
## recurses through a directory tree and prints it with indentation
sub recursedir {
my ($dir, $tab) = @_;
if (-d $dir) {
my @dir = glob("$dir/*");
foreach my $d (@dir) {
$d =~ /([^\/]+)$/;
my $fname = $1;
print " " x $tab, $fname, "\n" if -d $d;
if (-d $d) {
recursedir("$d",$tab+1);
}
}
} else {
print "error\n";
}
}
print ".\n";
recursedir('.',1);
Jump to Line
Something went wrong with that request. Please try again.