use strict;
use warnings;
my @levels = '.';
while (<DATA>) {
chomp;
my ($prefix, $node) = split(/(?<=-- )/, $_, 2);
my $level = length($prefix)/2-1;
$levels[$level] = "$levels[$level-1]/$node";
print("$prefix$levels[$level]\n");
}
__DATA__
|-- DIR_COLORS
|-- X11
| |-- WindowMaker
| | |-- WMGLOBAL
| | `-- WindowMaker
| |-- XF86Config
| |-- Xresources
| |-- Xsession
| |-- app-defaults
| | |-- Beforelight
| | |-- Bitmap
| | `-- Xvidtune
| |-- glx.conf
| |-- lbxproxy
| | `-- AtomControl
|-- xinetd.conf
|-- xinetd.d
| |-- cups-lpd
| |-- cvs
| |-- fam
| |-- proftpd-xinetd
| |-- rsync
| `-- sshd-xinetd
|-- xml
| `-- catalog
`-- xpdfrc
|-- ./DIR_COLORS
|-- ./X11
| |-- ./X11/WindowMaker
| | |-- ./X11/WindowMaker/WMGLOBAL
| | `-- ./X11/WindowMaker/WindowMaker
| |-- ./X11/XF86Config
| |-- ./X11/Xresources
| |-- ./X11/Xsession
| |-- ./X11/app-defaults
| | |-- ./X11/app-defaults/Beforelight
| | |-- ./X11/app-defaults/Bitmap
| | `-- ./X11/app-defaults/Xvidtune
| |-- ./X11/glx.conf
| |-- ./X11/lbxproxy
| | `-- ./X11/lbxproxy/AtomControl
|-- ./xinetd.conf
|-- ./xinetd.d
| |-- ./xinetd.d/cups-lpd
| |-- ./xinetd.d/cvs
| |-- ./xinetd.d/fam
| |-- ./xinetd.d/proftpd-xinetd
| |-- ./xinetd.d/rsync
| `-- ./xinetd.d/sshd-xinetd
|-- ./xml
| `-- ./xml/catalog
`-- ./xpdfrc
I would think
print("$levels[$level]\n");
would make more sense than
print("$prefix$levels[$level]\n");
but I gave you what you asked for.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|