http://www.mysite.com/sorting.pl?page=2 #### 200607140809.html (yyyy-mm-dd-hh-mm), ####

Galvanizing for Corrosion Protection - A Specifier's Guide to Reinforcing Steel

Corrosion and repair of corrosion damage aremulti-billion dollar problems. Observations on numerous structures show that corrosion of reinforcing steel is either a prime factor, or at least an important factor, contributing to the staining, cracking and spalling of concrete structures. These effects of corrosion often require costly repairs and continued maintenance during the life of the structure.

##
## #!/usr/bin/perl -wT use strict; use CGI qw/:standard/; $CGI::DISABLE_UPLOADS =1; my $page=param('page') || 0; unless ($page =~ m/^(\d+)$/) { die } $page = $1; opendir(DIRE, "/home/lenn287/public_html/diary")|| er_msg("cant open directory: $!"); #UPDATED #### my @files_exist = reverse sort map { $_ =~ s/^(\d+)\.html$/$1/; $_} grep { /^\w+.\.html$/} readdir DIRE; #### my @files_exist = reverse sort map { $_ =~ s/^(\d+)\.html$/$1/; $_} grep { /^\d+.\.html$/} readdir DIRE; closedir DIRE; my $how_many_page = sub { my ($how) = @_; $how = $how/5; $how =~ /(\d+?).?(\d+)?/; if(!$2) { return $1 } else { return $1+1 } }; my $file = sub { my $file_name = shift; my($topic,$title,$lang); open my $FH,'<', '/home/lenn287/public_html/diary/'.$file_name.".html"; while(<$FH>) { $topic = $1 if //; $title = $1 if //; $lang = $1 if //; } close $FH; return ($topic,br(),$title,br(),$lang,p()); }; if($page !~ /^[0-$how_many_page->($#files_exist)]$/) { print header,start_html,"invalid $page",end_html; exit(0); } my ($next,$previous); if($page < $how_many_page->($#files_exist)) { my $next_page=$page+1; $next = a({href=>"/cgi-bin/author.pl?page=$next_page"},"next"); } else { $next=''; } if($page > 0) { my $previous_page=$page-1; $previous = a({href=>"/cgi-bin/author.pl?page=$previous_page"},"previous"); } else { $previous=''; } my $first_file = $page*5; my $last_file = $page*5+4; my @FILES; #### for($first_file; $first_file<=$last_file;$first_file++) { push @FILES, $file->($files_exist[$first_file]); } #### for my $f($first_file..$last_file) { push @FILES, $file->($files_exist[$f]); } print header,start_html; print table({width=>720}, Tr( td({width=>720,colspan=>2}, img({src=>"/images/logo.gif",alt=>"logo", height=>90,width=>710}))), Tr( td({width=>600},@FILES), td({width=>120,rowspan=>100}, img({src=>"/images/banner.gif", height=>450,width=>120,alt=>"banner"})) ), Tr( td($next,$previous) )); undef $file; print end_html; #UPDATED, error message sub er_msg { my $error ="@_"; print header,start_html,p($error),end_html; die "$error"; }