R
Robert TV
Hi. I have a small perl script that opens a file, collects and assigns each
line of the file to an array, and then displays the data to the screen. This
script is working just fine, but is starting to get difficult to manage ...
you see, the data file now contains about 1,000 lines of data and it's
taking very long for perl to parse the data, assemble it into html and then
show in my browser (obviously it was very quick when the data file only had
10 enties total) Here is the jist of the script:
###### Start Script Example ######
#!/usr/bin/perl
open (FH, "<$user/datafile.db") or die "Can't open: $!";
@entires=<FH>;
close(FH);
print "Content-type: text/html \n\n";
print <<HTML;
<html>
<head>
<title>Database Results</title>
</head>
<body>
<table>
HTML
# DISPLAY DATABASE TABLES
chomp @entires;
foreach $entry(@entires) {
print <<HTML;
<tr>
<td width="42" height="19">Entry</td>
<td width="279" height="19">$entry</td>
</tr>
PRINTHTML
}
print <<HTML;
</table>
</body>
</html>
HTML
exit;
###### End Script Example ######
The database now at 1000 entires it takes very long to essemble and print to
screen, and it's bogging down my browser because the HTML is too long. Now,
I start to think ... I need a way to only show 20 or 30 results at a time,
and have "next results" or something similair ... kinda like search engines
do. So in an ideal world, I run the script and it only shows the first 30
lines of the array and has links to more results ... like this:
Showing 0-30 ---back 1 2 3 4 5 6 next #something like this.
I'm posting this inquiry because I have no idea how I would approach or
create such a feature, and I'm hoping that maybe a few of you out there
might be able to point me in the right direction, maybe there are some
tutorials, code snippets etc etc. I appriciate you taking time to read my
post! TIA
Robert TV
line of the file to an array, and then displays the data to the screen. This
script is working just fine, but is starting to get difficult to manage ...
you see, the data file now contains about 1,000 lines of data and it's
taking very long for perl to parse the data, assemble it into html and then
show in my browser (obviously it was very quick when the data file only had
10 enties total) Here is the jist of the script:
###### Start Script Example ######
#!/usr/bin/perl
open (FH, "<$user/datafile.db") or die "Can't open: $!";
@entires=<FH>;
close(FH);
print "Content-type: text/html \n\n";
print <<HTML;
<html>
<head>
<title>Database Results</title>
</head>
<body>
<table>
HTML
# DISPLAY DATABASE TABLES
chomp @entires;
foreach $entry(@entires) {
print <<HTML;
<tr>
<td width="42" height="19">Entry</td>
<td width="279" height="19">$entry</td>
</tr>
PRINTHTML
}
print <<HTML;
</table>
</body>
</html>
HTML
exit;
###### End Script Example ######
The database now at 1000 entires it takes very long to essemble and print to
screen, and it's bogging down my browser because the HTML is too long. Now,
I start to think ... I need a way to only show 20 or 30 results at a time,
and have "next results" or something similair ... kinda like search engines
do. So in an ideal world, I run the script and it only shows the first 30
lines of the array and has links to more results ... like this:
Showing 0-30 ---back 1 2 3 4 5 6 next #something like this.
I'm posting this inquiry because I have no idea how I would approach or
create such a feature, and I'm hoping that maybe a few of you out there
might be able to point me in the right direction, maybe there are some
tutorials, code snippets etc etc. I appriciate you taking time to read my
post! TIA
Robert TV