Settings

The page will reload to apply your changes.
Theme

ASCII Art Font

ASCII Art Menu

Original Usenet message from alt.ascii-art, 9 Jul 2005.
perl ascii - tree

perl ascii - tree

From: <http://www.perlmonks.org/?node_id=452201>
Usage: perl tree.pl
This will give output similar to the *nix tree(1) program.

#!/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


-- 
Mark Hill

Original message headers
X-Google-Thread: f996b,a6e181f2eb5802b3,start
X-Google-Attributes: gidf996b,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news4.google.com!news.glorb.com!feeder.xsnews.nl!130.133.1.3.MISMATCH!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Mark Hill <m...@rk.invalid>
Newsgroups: alt.ascii-art
Subject: perl ascii - tree
Date: 9 Jul 2005 23:41:34 GMT
Lines: 36
Message-ID: <200...@blackhole.markhill.me.uk>
X-Trace: individual.net 5ZDRX4r1jBoTmeYDJuWQpQEaMGN+dhDRZwoZ9WV5Z1qfRPpF75
User-Agent: slrn/0.9.8.1 (Linux)
Xref: g2news1.google.com alt.ascii-art:4286

Related ASCII art in the Gallery

Explore these categories from our collection of 11,000+ artworks:

About this message. This message was posted publicly to the newsgroup alt.ascii-art in 2005 and is mirrored here unchanged as part of the Historic Archives – only email addresses are masked. The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can. Are you the author? Contact us to get your posts attributed, connected to your artist profile, or removed.

Report this message

Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.

Help classify this post