Settings

The page will reload to apply your changes.
Theme

ASCII Art Font

ASCII Art Menu

Original Usenet thread from alt.ascii-art, started 9 Jul 2005.
 _   _                     _        _             _     _           
| | | |___  ___ _ __   ___| |_     / \   _ __ ___| |__ (_)_   _____ 
| | | / __|/ _ \ '_ \ / _ \ __|   / _ \ | '__/ __| '_ \| \ \ / / _ \
| |_| \__ \  __/ | | |  __/ |_   / ___ \| | | (__| | | | |\ V /  __/
 \___/|___/\___|_| |_|\___|\__| /_/   \_\_|  \___|_| |_|_| \_/ \___|
perl ascii - tree

perl ascii - tree

alt.ascii-art · 1 message · 9 Jul 2005
Mark Hill <m...@rk.invalid> ASCII art 9 Jul 2005 23:41 · raw headers · report
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

Related ASCII art in the Gallery

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

About this thread. These messages were posted publicly to the newsgroup alt.ascii-art in 2005 and are 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 one of the authors? 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