You just want each page to have the links for the files/directories in that
immediate directory?  np...

## Warning, written on Unix, not tested in windows
# This creates an HTML page in each directory with links for that directory, like
a
# directory listing in a web browser.

$startingdir='/home/testsomething';
$index='index.html';

chdir $startingdir or die;
chdir '..';  # back up for a running start

$startingdir=(reverse split '/', $startingdir)[0]; #basename

link_maker($startingdir);  # recursive sub to do the work

sub link_maker {
   my $dir=shift;
   local (*INDEX, *DIR);

   return if -l $dir;    # ignore links, do they exist on win32?
   chdir $dir or return; # can't read directory

   open INDEX, ">$index" or do {chdir '..'; return}; #can't write here
   print INDEX qq{<a href="../">../</a><br>\n} if ($dir ne $startingdir);

   opendir DIR, '.';
   foreach (readdir DIR) {
      next if /^\./ || /^$index$/;       # ignore $index and .files
      -d $_
         ? print INDEX qq|<a href="$_/$index">$_/</a><br>\n|
         : print INDEX qq|<a href="$_">$_</a><br>\n|;
      link_maker($_) if -d $_;  # go recursive
   }
   close DIR; close INDEX;
   chdir '..';
}


Douglas Wilson wrote:

> On 05/22/00, "Eduard Pandele <[EMAIL PROTECTED]>" wrote:
>
> > 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
>
> I don't quite get what you're after, but maybe File::Find
> would help. It will traverse and cd (if desired) to every directory
> for you. Once in the directory, you could use
> opendir/readdir/closedir to read all the directories
> and/or files in the current directory.
>
> HTH,
> Douglas Wilson
>
> ---
> You are currently subscribed to perl-win32-users as: [EMAIL PROTECTED]
> To unsubscribe, forward this message to
>          [EMAIL PROTECTED]
> For non-automated Mailing List support, send email to
>          [EMAIL PROTECTED]


---
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]

Reply via email to