graff,

Here is what I have so far. Unfortunately, I haven't worked out a few things like having it only read the files in the directories and excluding the subdirectories in directory_contents. I am getting duplicates.

I have been shown a few other things, but haven't quite gotten the kinks worked out of those either.

#!/usr/bin/perl use strict; use warnings; use diagnostics; use File::Find; use File::Spec; my $rootdir = "C:/Documents and Settings/<my name>/My Documents/fantas +y"; my @files; sub wanted { my $text = $File::Find::name; push @files, $text; return; } sub directory_contents { my ($contents) = @_; my $file_tab = $contents; $file_tab =~ s{$rootdir}{}; my $tab = "\t" x ($file_tab =~ tr{/}{}); my @list = (map("$tab<li>".$_."</li>\n",grep{m/^($contents)\//} @fil +es)); #the grep is where I think I need to put the stop on going lowe +r. return join("",@list); } sub print_directory { my ($file) = @_; my $file_tab = $file; $file_tab =~ s{$rootdir}{}; my $tab = "\t" x ($file_tab =~ tr{/}{}); my $directory = qq{$tab<li>$file\n$tab<ul>\n}.directory_contents($fi +le).qq{$tab</ul>\n$tab</li>\n}; print $directory; } find(\&wanted, $rootdir); foreach my $entry (File::Spec->no_upwards(@files)) { print_directory($entry) if -d $entry; }
Have a nice day!
Lady Aleena

In reply to Re^4: Directory Tree Structure by Lady_Aleena
in thread Directory Tree Structure by rupesh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.