View Full Version : Searching for Perl script
2kewl
03-14-2000, 07:57 PM
Hi,
I'm searching for a Perl script which will display the contents of a character "|" delimited database file. Something like a guestbook without the ability to add entries, just simply to display on a HTML page. Help please.<!-- NO_AUTO_LINK -->
urban
03-15-2000, 03:44 PM
You describe a script that is (in all likelihood) fairly easy to develop.[nbsp][nbsp]I doubt you'll find a completely 'generalized' script that will just automatically work with your file.[nbsp][nbsp]However, if you post more details, someone will most likely be able to assist you.
What are the fields separated by the '|'?[nbsp][nbsp]How many fields are there?[nbsp][nbsp]How do you want to display each field?[nbsp][nbsp]Etc...
open(FH,'/big/dom/x-whatever/somedir/myflatfile.txt);
while(<FH>) {
[nbsp]($field1,$field2,$field3,$field4) = split(/\|/);
[nbsp]print "FieldOne = ".$field1."
\n";
[nbsp]print "FieldFour = ".$field4."
\n";
}
2kewl
03-15-2000, 06:32 PM
Easy for some maybe for not for me. I'm looking for a ready-made script. There must be one somewhere!
The database file is written by my form mailer (ennyforms) from fields entered into a form and also emails me the form. Here's a sample of the database:
|xxxxx@xxxxx.com|Sandra|USA|Female|22|epals|English||I look forward to making epals from all over the world, especially from Asia and Europe. I like learning about different cultures and languages. Friendship only. Age and gender doesn't matter. Hope to hear from you soon.|
There are lots of scripts which record in a database but none, it seems, which will simply write it to a HTML page. Lots of DBMs of course, but they all include adding to the database and searching which I don't want.
As I said just a simple centre-stacked page maybe just like a guestbook.
The purpose is to display latest pen pal ads.
ANDY
<!-- NO_AUTO_LINK -->
[This message has been edited by 2kewl (edited 03-15-00@5:34 pm)]
Dan Kaplan
03-16-2000, 01:40 AM
A possible solution would be using Gossamer Thread's DBMan with no login and a "list all" by default.[nbsp][nbsp]That would effectively be the same as just listing all the database info on one page.[nbsp][nbsp]You can format the output pretty much however you want.
The challenge might lie in syncing the ennyforms and DBMan database formats...
http://www.gossamer-threads.com
Dan
sumengen
03-23-2000, 08:25 AM
Hi,
If you save the code below to a file and run it in your cgi dir, it will be creating a table with the information in your data file. You should edit the $data_path and $data_file variables.
#!/usr/bin/perl -w
my $data_path = "/path/to/your/data/directory";
my $data_file = "data.txt";
open(FILE, "$data_path/$data_file") or die "Can't open $data_file";
flock(FILE, 2);
my @records = <FILE>;
flock(FILE, 8);
close(FILE);
chomp(@records);
my ($html);
for (@records){
[nbsp][nbsp] $html .= "<tr><td>" . join("</td><td>", map {s#^$#\&nbsp;#g;$_} eval{my @temp = split /\|/; shift(@temp) unless($temp[0]); @temp} ) . "</td></tr>";
}
$html = '<table border="1" width="100%">' . $html . '</table>';
print "Content-type: text/html\n\n";
print $html;
------------------
*****************
Baris Sumengen
*****************
vBulletin® v3.6.8, Copyright ©2000-2009, Jelsoft Enterprises Ltd.