Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Tree

by dave0 (Friar)
on Apr 28, 2005 at 03:17 UTC ( [id://452201]=obfuscated: print w/replies, xml ) Need Help??

#!/usr/bin/perl -w use strict; my ($p, $s,$d); grep { # /-.?s/&&## $s++; /-.?d/ &&$d++;}@ARGV; (($p = $ARGV[-1] || ".") !~ /^-/)|| ($p=".");print"$p\n"; d($p,0,0);my$kr; sub d{ my($p,$x,$v)=@_;opendir(D, $p)or warn"Can't read $p:$!" ;my@d;map {my($k,$r,$y,$l)=(# "$p/$_", " ",($_ eq $d[-1]),''); print map {($_ ? "|":" ") ." "x3} (split(//,unpack("b*", $v)))[0..($x - 1)];if(-l$k){$l = readlink($k);;$r= ' -> '.(-e$l?$l:"($l)");-l$k;}print $y? '`':'|',"-- ",$s ?sprintf("[%9d] ",-s _): '',$_,$r,"\n";if(!-l _&&-d _){vec($v,$x,1)= !$y;d($k,$x+1,$v);};}(@d=sort grep{(-d"$p/$_" ||!$d)&& !/^\./}# readdir# D);}#DMO

I found this one again while cleaning out my home directory, so I thought I'd share it. It's a partial work-alike for the UNIX 'tree' command I wrote four years ago for a local LUG's programming contest (see http://oclug.on.ca/pwars/April2001/).

Replies are listed 'Best First'.
Re: Tree
by liverpole (Monsignor) on Nov 18, 2005 at 04:52 UTC
    I don't know how I missed this one before; great idea and presentation both! ++
Re: Tree
by Anonymous Monk on Apr 28, 2005 at 17:25 UTC
    Cool !

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://452201]
Approved by Tanktalus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2025-06-17 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.