Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-09-15 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.