FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Coding/Development
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 01-29-1999, 03:26 PM   Postid: 15415
jbroder
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Dec 1998
Location: oakland, ca, usa
Posts: 138
Perl Directory Index

Now that I have formmail set up on futurequest LOTS of people send me files to post on my site. It is getting really annoying rewriting the table that holds the lins to there files. So, I took a perl class
and wrote a script (my first!) that reads the directory and provides links to each file.

http://www.guitartricks.com/cgi-bin/11.cgi

Here is the script, which works fine as far as I can tell:

##########################################

#!/usr/local/bin/perl -w
print "Content-type: text/html\n\n";
print '<html>' ;
print "whoo!!!
" ;
opendir (HTDOCS,"/big/dom/xguitartricks/jbroder/www/your/") ;

foreach (readdir(HTDOCS)) {
if ($_=~/\.html$/) {
print "<a href=\"http://www.guitartricks.com/your/$_\">$_</a>
" ;

}
}
print "<img src=\"http://guitartricks.com/images/gtban.gif\">" ;
print '</html>' ;
###########################################

This is quite a plain doc and I would like to make it more informative.

My question is how do I take each file name
and search thru that file to find the text between the <h2></h2> tags and print it to
the screen right next to the link? It would
then say something like

your12.html contributed by Jon Doe from Canada.

I have tried to setup readdir(YOUR) as an array and I have tried to just use
foreach ($_){
if (/h4/){
print "" ;
}
}
but have had no luck.

Thanks in advance.

Jon

------------------
guitartricks.com
jbroder is offline   Reply With Quote
Old 01-30-1999, 10:53 PM   Postid: 15416
ChrisH
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Jan 1999
Location: Long Island, New York
Posts: 75


If $foo has the name of the file, you
can try this:

open (FILE, $foo);
while (defined ($line = <FILE> ))
{ if ($line =~ m!<h2>(.*?)</h2>!i)
{ print "Head 3 was $1.\n"; }
}

This works if the entire h2 is on one
line. If not, you have to read the whole
file in and search it as one big line -
easy to do in perl also.


ch


ChrisH is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 03:36 AM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.