You don't really need Per tree structures. The directory is already tree
structured, so what you need to do is to walk the directory tree producing
the output directly.
Walk a single level of the directory. If the file is a directory, either
process it immediately or place it in an array (a stack) and process the
included directories at the end.
Untested code:
sub dir_out
{
my $dir = shift;
my @dirs = (); # New stack at each level
opendir( DIRH, $dir ) or die "Failed to open directory $dir: $! );
my @files - readdir( DIRH );
closedir( DIRH );
# Emit the start of the HTML file here, generating names however you
choose
foreach $file ( sort @files )
{
if ( -d $file )
{
# Save the directory
push( @dirs, $file );
# Emit link to lower HTML file as desired
}
else
{
# Emit HTML for $file hers
}
} # @files
# Finish this HTML file
# Process directories recursively
foreach $dir ( @dirs )
{
dir_out( $dir );
}
} # dir_out
This ignores issues of full path vs. file name, bunches of stuff about how
the HTML looks, and other niceties. It is intended only to demonstrate that
you already have a tree structure to walk, and that is in the directory
structure itself.
Thanks,
Garold (Gary) L. Johnson
DYNAMIC Alternatives
Eduard Pandele wrote
Hello !
This is my problem : I have to build a hierarchical menu in HTML from a
tree of directories.
Let's say I have this directory structure :
root/
root/one
root/one/a
root/one/b
root/two
root/three
root/three/a
I must get a series of html documents which should allow me to "walk"
through the directories structure :
index.html which contains the three links to one, two and three
one.html which contains something like
one
- a
- b
two
three
etc...
I could made up a simple program to do this, if only i could implement
somehow a tree data structure in Perl (after all, I should use a tree
construction algorithm and walk through this tree to generate the html
files).
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]