in reply to How to generate an HTML page from an FTP directory listing?

If you are using Net::FTP to get a listing then you've alreadly done half of the work. Net::FTP's list function should give you all of the files in an array. After you have that just print the start of the page either using CGI.pm or you can hand code it (best done in a here doc). Then just use a foreach loop to print each entry:

foreach my $file (@file_list) { print "<p>$file</p>\n"; #This is basic, format as required. }


After that just send the page ending stuff (</body>, </html>) the same way you generated the beginning of the page.

-THRAK
www.polarlava.com

Replies are listed 'Best First'.
Re: Re: How to generate an HTML page from an FTP directory listing?
by Anonymous Monk on Mar 28, 2001 at 22:07 UTC
    (from original author)

    It's the formatting part that I have a question on. Is there an existing script/tool that will take the directory listing and format it for me (creating links for each file/directory, etc.), or do I need to do that manually? (I know, I know, doing it manually isn't that big a deal for you experienced guys out there, but when you're just starting out, just about anything can be intimidating...) :)

    Thanks again.

      Wouldn't something as simple as:

      print <<"END" <a href="ftp://server/path/$file">$file</a><br> END
      work?

              - tye (but my friends call me "Tye")
      Well, there's probably nothing "out of the box" that does exactly what you want (yet, because I've noted this problem for a future column idea), but take a look at my past columns for ideas on how to generate links based on names, and how to respond to those links when selected.

      -- Randal L. Schwartz, Perl hacker