Menu tree from Hard disk

I look for a sollution to let people view a part of a harddisk (let's say c:\data and it's submenu's) in a menu style like this:
c:\data
   + word documents
       + Sales
       + Vendor
   + Excell Sheets
       + Sales

Do someone have here a sollution.

This must be just show a Hard disk tree with the current files in it.

I start with 100 points and go up if I found realy something.

Mario
LVL 6
LermitteAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MindoCommented:
Damn, while at the Perl exam at my university i had to write a recursive file directory representation just like for you. I wrote it, got my grade and deleted it! What a shame :-(
0
LermitteAuthor Commented:
That's indeed a shame, I know java and HTML but I have not the expertise to write something like I need now. And I need it Fast...

Mario
0
LermitteAuthor Commented:
Adjusted points to 125
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

MindoCommented:
Ok, wait an hour, i'm writing it once again :-)
0
LermitteAuthor Commented:
This will be great...

Mario
0
LermitteAuthor Commented:
You can send it to lermitte@pandora.be
If it's to big to place it here.

Mario
0
ozoCommented:
use File::Find;
find(\&wanted,'c:/data');
sub wanted{print "  "x($File::Find::dir=~tr:/:/:),"  + $_\n"}
0
MindoCommented:
I'm unlucky, an expert provided an answer just before i wrote it. Mario? Should i proceed doing this? My answer isn't so nice as ozo's :-(
0
MindoCommented:
My answer differentiates directories from files.
0
MindoCommented:
#!/usr/local/bin/perl -w

use File::Find;

push(@DIR, $ARGV[0]);

$c = count_slashes($ARGV[0]);

find (\&process_file, @DIR);

#--------------------------------------------------------

sub process_file
{
  $file_name = $File::Find::name;
 
  $count = &count_slashes($file_name) - $c;
 
  $start = "";
 
  for($i = 0; $i < $count; $i++)
  {
    $start .= "  ";
  }
 
  if(-d $file_name)
  {
    $start .= "+ ";
  }  
  else
  {
    $start .= "- ";
  }
 
  $start .= $_;
 
  print "$start\n";
}

#--------------------------------------------------------

sub count_slashes
{
  my($file_name) = shift;
 
  $seen{"/"} = 0;
 
  foreach (split //, $file_name)
  {
    $seen{$_}++;
  }
 
  return $seen{"/"};
}

#--------------------------------------------------------
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MindoCommented:
I'm dead, ozo's answer is a real piece of code!

Nevertheless, my answer accepts directories from the command line. Also, it lets you add different symbols depending on the type of your file: directory/plain file.
0
LermitteAuthor Commented:
Second question. How can I integrate this in a HTML file...

Don't panic I can give point to your both...

Mario
0
LermitteAuthor Commented:
Second question. How can I integrate this in a HTML file...

Don't panic I can give point to your both...

Mario
0
MindoCommented:
Ok, do the following:

Name your Perl source file perl.cgi. Give it permissions so that people could see it on the web. Give it a parameter directory name through CGI. Then print the HTML tags and inside print the results of this program.
0
MindoCommented:
I think you should post it as a new question to receive full source code.
0
LermitteAuthor Commented:
It's not exact what we want put we have working on it and now we have a sollution to view a tre menu in a webpage.

Thanks,

Mario
0
LermitteAuthor Commented:
Ozo look for a question special for you.

Mario
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.