#!/usr/local/bin/perl # -*- C -*- # # booklist.cgi for chiyoda bookstore # { my($buf); if ($0 =~ /^(.*)\/[^\/]+$/) { $buf = $1; } elsif ($0 =~ /^(.*)\/$/) { $buf = $1; } elsif ($0 !~ /\//) { $buf = '.'; } require "$buf/../pan.pl"; } open(IN, "template.html"); while ($buf = ) { $tmpl .= $buf; } close(IN); open(IN, "index.txt"); while ($buf = ) { $buf =~ s/\015\012/\t/g; $buf =~ s/\012/\t/g; $buf =~ s/\015/\t/g; $bufs .= $buf; } close(IN); @records = split(/\t/, $bufs); foreach $record (@records) { ($key, $value) = split(/=/, $record, 2); $fields{$key} = $value; } $tmpl =~ s/%%dates%%/$fields{'dates'}/g; $tmpl =~ s/%%datee%%/$fields{'datee'}/g; for ($i = 0; $i < 10; $i++) { $tmpl =~ s/%%lastrank$i%%/$fields{"lastrank$i"}/g; $rc = $fields{"recommend$i"}; if ($rc ne '') { $rc = "$rc"; } $tmpl =~ s/%%recommend$i%%/$rc/g; $tmpl =~ s/%%title$i%%/$fields{"title$i"}/g; $tmpl =~ s/%%writer$i%%/$fields{"writer$i"}/g; $tmpl =~ s/%%publisher$i%%/$fields{"publisher$i"}/g; $tmpl =~ s/%%price$i%%/$fields{"price$i"}/g; $tmpl =~ s/%%comment$i%%/$fields{"comment$i"}/g; } 'noheader ssi' =~ /$ARGV[0]/i or &declare_html; print emulate_SSI($tmpl);