#!c:/xampp/perl/bin/perl.exe
use warnings;
use CGI;
use Time::HiRes qw(gettimeofday);
my $query = CGI->new;
my $dir = "C:/Users/41786/OneDrive/Documents/recordz1/";
print $query->header;
test();
sub test {
my $counter = 1000; #Should be get from db;
my $string = "";
my $first_page = 0;
my $min_index = $query->param("min_index");
if ($min_index = '') {
$min_index = 0;
}
open (FILE, "<$dir/test2.html") or die "cannot open file $dir/test2.html";
my $content = "";
my $max_index = $query->param("max_index");
if ($max_index = '') {
$max_index = 40;
}else {
$max_index = round ($counter / 40, 1);#Number of objects displayed per page.
}
my $last_page = $nb_page - 1;
my $n2 = 0;
my $count_per_page = 10;
my $index_page = 0;
for my $index (0..$max_index) {
$next_page = $min_index + 40;
if ($index < $count_per_page) {
if (($index % $count_per_page) > 0) {
$string .= "<-$index_page-> ";
}
}
$index_page++;
$min_index += 40;;
}
$string .= "<-\"Next\"-> ";
while () {
s/\$ARTICLE{'index'}/$string/g;
$content .= $_;
}
print $content;
close (FILE);
}
sub round {
my $n = shift || '';
my $r = sprintf("%.0f", $n);
return $r;
}