MLUG: FW: [MLUG - DISCUSSION] Dumb Perl Question
FW: [MLUG - DISCUSSION] Dumb Perl Question
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Here is a little more refined version which makes sure the links displayed
are ordinary files (not directories, etc.) and adds a title to the page.

#! /usr/bin/perl

use CGI;

$show_base = "/usr/local/apache/htdocs/";
$show_dir = "manual";

$cgi = new CGI;

$html_title = 'Listing of the directory '.$show_dir;

print $cgi->header();

print $cgi->start_html($html_title);

opendir(DIR, $show_base.$show_dir) || die "can't opendir $show_dir: $!";

@files = readdir(DIR);

closedir DIR;

print "<H1>$html_title</H1>\n";
print "<HR>\n";

foreach $file_name (@files)
   {
   if (-f $show_base."/".$show_dir."/".$file_name)
      {
      print "<A HREF=\"/$show_dir/$file_name\">", $file_name, "</A><BR>\n";
      }
   }

print $cgi->end_html;

-----Original Message-----
From: Anderson, Bill 
Sent: Tuesday, May 07, 2002 2:21 PM
To: EMAIL:PROTECTED; 'Davis, Ryan Wiley (UMC-Student)'
Subject: RE: [MLUG - DISCUSSION] Dumb Perl Question


How about this for a very rough starting point:

### Code starts here

<- snip ->

### Code ends here

Bill Anderson

-----Original Message-----
From: EMAIL:PROTECTED
[mailto:EMAIL:PROTECTED]On Behalf Of Davis, Ryan
Wiley (UMC-Student)
Sent: Tuesday, May 07, 2002 1:12 PM
To: EMAIL:PROTECTED
Subject: [MLUG - DISCUSSION] Dumb Perl Question


Okay,

So I am looking for a bit of perl to put into a CGI and I am kindof lost on
exactly how to do it. Let me describe.

I want the perl to read the filenames in a certain sub directory of my web
account. There are a few files 10-30 in this directory. I would then like
the perl code to output (into HTMLof course) the listing of said directory
and a link to access all these files. 

I'm currently messing with different ways of doing this, but wanted to know
if any of you monkeys out there have already done something like this and
have a quick and easy solution.

-Ryan

--
To unsubscribe, go to http://mlug.missouri.edu/members/edit.php

Archives are available at http://mlug.missouri.edu/list-archives/
--
To unsubscribe, go to http://mlug.missouri.edu/members/edit.php

Archives are available at http://mlug.missouri.edu/list-archives/