I got this code by Matthew Keller from the internet that is supposed to create a dynamic list of links to directories in an HTML file. I run the code through a parser and get errors all over it. Here is the code directly from his site, I of course change the paths to my enviroment:
#!/usr/bin/perl -w
sub Get_Title {
my =shift;
unless(-f "") { return("NO INDEX"); }
open(HTML,"<");
while(<HTML>){
if(sh=~ /<title>(.*)<\/title>/i) {
close HTML;
return "";
}
}
close HTML;
return "Untitled";
}
my ="/usr/local/apache/htdocs/projects/";
my ="http://mattwork.potsdam.edu/projects/";
opendir(PRJD,"");
my @dirs=readdir PRJD;
closedir(PRJD);
print "Content-Type: text/html\n\n";
print "<html><head><title>Project Index Page</title></head><body>\n";
for(@dirs) {
if(sh=~ /^\./) { next; }
unless(-d sh) { next; }
my ="sh/index.html";
my =Get_Title("");
=~ s///i;
print "<a href=\ "\ "></a>\n";
}
I do not know perl and have been trying to work on this for almost a week now. If anyone could help I would appreciate it.
Thanks in advance.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.