Even if I add a second or third set of data, the order remains intact
for me.
I still cannot reproduce this.
Tassilo
If I use the code below on the html file called test.htm (contents
below) which is in the d:\a-keep9\short-nondb\oldshort3 folder amd
db.txt (contents below) which is the d:\a-keep9\short-nondb\db
I get
<h2>test first</h2>
<p> ashjk hjk etc first </p>
<h2>test second</h2>
<p> ahsj hk jk etcsecond </p>
followed by the 2 option sections
instead of
<h2>test first</h2>
<p> hdjsadh jkashd jk etc first</p>
<option etc
<h2>test fsecond</h2>
<p> jak jahd jaksd j ksecond </p>
<option etc
Any use?
Cheers
Geoff
------------- test.htm ------------
<html>
<head><title>test</title>
</head>
<body>
<h2> test first </h2>
<p> ahsjdhj akdh hasdj jakhd k ada
dkasdjl akld kajd kl as
aksjd lajksd aldsj first</p>
<option
value="docs/gcse/student-activities/business-location">Business
Location</option>
<h2> test second</h2>
<p> ahdjk ahsdjh ahd
akjdk akld asjd la
adj ajsdk lk second </p>
<option
value="docs/gcse/student-activities/business-location">Business
Location</option>
</body>
</html>
------------------------------ db.txt ----------------------
INSERT INTO total VALUES
('docs/gcse/student-activities/finance','<h3>GCSE Student Activities -
Finance</h3>1. methods of raising finance<br>2. don\'t call them
money<br>3. coloured breakeven point<br>4. The mug activity<br>5.
Cashflow and inflow<br>6. external influences on breakeven<br>7.
balance sheet<br>8. which account will you get me from');
INSERT INTO total VALUES
('docs/gcse/student-activities/marketing','<h3>GCSE Student Activities
- Marketing</h3>1. adverts-activity<br>. demand-and-supply<br>3.
market-research<br>4. market-segments<br>5. product-life-cycle<br>6.
promotions-and-business-objectives<br>7. supply-and-demand-2<br>8.
the-marketing-mix-and-types-of-economy<br>9. the-marketing-mix<br>10.
types-of-market-and-demand-and-supply<br>11.
types-of-ownership-and-the-marketing-mix');
-------------------------------------- the code -------------
package MyParser;
use base qw(HTML:
arser);
use strict;
use diagnostics;
my ($in_heading,$in_p, $fh);
sub register_fh {
# $_[0] contains the parser object
$fh = $_[1];
}
sub reset { ($in_heading,$in_p)=(0,0)}
sub start {
my ( $self, $tagname, $attr, undef, $origtext ) = @_;
if ( $tagname eq 'h2' ) {
$in_heading = 1;
return;
}
if ( $tagname eq 'p' ) {
$in_p = 1;
return;
}
if ( $tagname eq 'option' ) {
print ("\$origtext has value $origtext \n");
main::choice( $attr->{ value } );
}
}
sub end {
my ( $self, $tagname, $origtext ) = @_;
if ( $tagname eq 'h2' ) {
$in_heading = 0;
return;
}
if ( $tagname eq 'p' ) {
$in_p = 0;
return;
}
}
sub text {
my ( $self, $origtext ) = @_;
print $fh "<h2>$origtext</h2> \n" if $in_heading;
print $fh "<p>$origtext</p> \n" if $in_p;
}
package main;
use File::Find;
my $dir = "d:/a-keep9/short-nondb/oldshort3";
my $parser = MyParser->new;
find sub {
return if /^\.\.?/; # catches "." and ".."
my $name = $_;
open( OUT, ">>d:/a-keep9/short-nondb/short/members2/$name" )
|| die "can't open d:/a-keep9/short-nondb/short/members2/$name:
$!";
print OUT ("<html><head><title>test</title>
<link rel=\"STYLESHEET\" type=\"text/css\"
href=\"assets/style/hala-1.css\">
</head><body> \n");
print OUT ("<table width='100%' border='1'> \n");
# undef $/;
$parser->register_fh(\*OUT);
$parser->parse_file($_);
$parser->reset;
print OUT ("</body></html> \n");
}, $dir;
sub choice {
my ($path) = @_;
if ( $path =~ /docs\/btec-first/ ) {
intro($path);
btecfirst($path);
}
elsif ( $path =~ /docs\/aslevel\/classroom-notes/ ) {
intro($path);
aslevelclassroomnotes($path);
}
elsif ( $path =~ /docs\/avce\/assignments/ ) {
intro($path);
avceassignments($path);
}
elsif ( $path =~
/docs\/aslevel\/simulations\/second-severn-bridge/ ) {
intro($path);
aslevelsimulationssevern($path);
}
elsif ( $path =~ /docs\/aslevel\/debates\/wind-farm-debate/ ) {
intro($path);
asleveldebateswindfarm($path);
}
elsif ( $path =~ /docs\/economics\/section1/ ) {
intro($path);
economicssection1($path);
}
elsif ( $path =~ /docs\/economics\/section2/ ) {
intro($path);
economicssection2($path);
}
elsif ( $path =~ /docs\/economics\/section3/ ) {
intro($path);
economicssection3($path);
}
elsif ( $path =~ /docs\/gcse\/classroom-notes/ ) {
intro($path);
gcseclassroomnotes($path);
}
elsif ( $path =~
/docs\/gcse\/student-activities\/games\/ice-lolly/ ) {
intro($path);
gcsegamesicelolly($path);
}
elsif ( ( $path =~ /docs\/gnvq-int\/assignments/ )
&& ( $path !~
/gnvq-int\/assignments\/gnvq-int-write-assignment/ ) )
{
intro($path);
gnvqintassignments($path);
}
elsif ( $path =~ /docs\/vgcse\/course-units/ ) {
intro($path);
vgcsecourseunits($path);
}
elsif ( $path =~
/docs\/gcse\/student-activities\/business-location/ ) {
intro($path);
gcsestudentactivitiesbusinesslocation($path);
}
elsif ( $path =~
/docs\/gcse\/student-activities\/business-structure-decisions/ )
{
intro($path);
gcsestudentactivitiesbusinessstructuredecisions($path);
}
elsif ( $path =~ /docs\/gcse\/student-activities\/finance/ ) {
intro($path);
gcsestudentactivitiesfinance($path);
}
elsif ( $path =~ /docs\/gcse\/student-activities\/marketing/ ) {
intro($path);
gcsestudentactivitiesmarketing($path);
}
elsif ( $path =~ /docs\/gcse\/student-activities\/people-at-work/
) {
intro($path);
gcsestudentactivitiespeopleatwork($path);
}
elsif ( $path =~ /docs\/gcse\/student-activities\/production/ ) {
intro($path);
gcsestudentactivitiesproduction($path);
}
else {
intro($path);
other($path);
}
}
sub intro {
my ($pathhere) = @_;
open( INN, "d:/a-keep9/short-nondb/db/db.txt" );
my $lineintro;
while ( defined( $lineintro = <INN> ) ) {
if ( $lineintro =~ /$pathhere','(.*?)'\)\;/ ) {
print OUT ("<tr><td>$1 <p> </td>\n");
}
}
}
sub btecfirst {
my ($pattern) = @_;
my $linee = $pattern;
my $c = 0;
$linee =~ /.*unit(\d).*?chap(\d)/;
my $u = $1;
my $chap = $2;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d);/ ) {
my $nn = $1;
print OUT ("<td valign='top'>\n");
for ( my $c = 1 ; $c < $nn ; $c++ ) {
print OUT (
'<a href="' . $pattern . "/unit" . $u . "-chap" .
$chap . "-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub aslevelclassroomnotes {
my ($pattern) = @_;
my $c;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
my $line = <INNN>;
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern . "-doc" . $c .
".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub other {
my ($pattern) = @_;
print OUT ("<td valign='top'> \n");
print OUT ( '<a href="' . $pattern . ".zip" . '">'
. "Document"
. "</a><br>"
. "\n" );
print OUT ("</td></tr>\n");
}
sub avceassignments {
my ($pattern) = @_;
print OUT ("<td valign='top'> \n");
print OUT ( '<a href="' . $pattern . ".zip" . '">'
. "Document"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern . "-grid" . ".zip" . '">' .
"Grid"
. "</a><br>"
. "\n" );
print OUT ("</td></tr>\n");
}
sub aslevelsimulationssevern {
my ($pattern) = @_;
print OUT ("<td valign='top'> \n");
print OUT ( '<a href="' . $pattern . ".zip" . '">'
. "Teacher's pack"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern . "-sp" . ".zip" . '">'
. "Student's Pack"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern . "-swb" . ".zip" . '">'
. "Student's Workbook"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern . "-dbp" . ".zip" . '">'
. "Debriefing Pack"
. "</a><br>"
. "\n" );
print OUT ("</td></tr>\n");
}
sub asleveldebateswindfarm {
my ($pattern) = @_;
print OUT ("<td valign='top'> \n");
print OUT ( '<a href="' . $pattern . ".zip" . '">'
. "Teacher's pack"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern
. "-a-company" . ".zip" . '">'
. "Adviser's Pack - Company"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern
. "-a-council" . ".zip" . '">'
. "Adviser's Pack - Council"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern
. "-s-company" . ".zip" . '">'
. "Student's Pack - Company"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern
. "-s-council" . ".zip" . '">'
. "Student's Pack - Council"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern
. "-s-workbook" . ".zip" . '">'
. "Student's Workbook"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern
. "-arbitrator" . ".zip" . '">'
. "Arbitrator's Pack"
. "</a><br>"
. "\n" );
print OUT ("</td></tr>\n");
}
sub economicssection1 {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/section1-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub economicssection2 {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/section2-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub economicssection3 {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/section3-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub gcseclassroomnotes {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern . "-doc" . $c .
".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub gcsegamesicelolly {
my ($pattern) = @_;
print OUT ("<td valign='top'> \n");
print OUT ( '<a href="' . $pattern . ".zip" . '">'
. "Teacher's Pack"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern
. "-runners" . ".zip" . '">'
. "Runner's Pack"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern
. "-adjudicators" . ".zip" . '">'
. "Adjudicator's Pack"
. "</a><br>"
. "\n" );
print OUT ("</td></tr>\n");
}
sub gnvqintassignments {
my ($pattern) = @_;
print OUT ("<td valign='top'> \n");
print OUT ( '<a href="' . $pattern . ".zip" . '">'
. "Document"
. "</a><br>"
. "\n" );
print OUT ( '<a href="' . $pattern . "-grid" . ".zip" . '">' .
"Grid"
. "</a><br>"
. "\n" );
print OUT ("</td></tr>\n");
}
sub vgcsecourseunits {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern . "-chap" . $c .
".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub para {
my ($name) = @_;
my $line;
open( INPARA, "d:/a-keep9/short-nondb/progs/para2/$name" );
undef $/;
$line = <INPARA>;
print OUT ("<tr><td colspan='2'> \n");
print OUT $line;
print OUT ("</td></tr> \n");
$/ = "\n";
}
sub getpara {
local $/ = "\0d\0a";
my ($name) = @_;
my $line;
open( GETPARA, "d:/a-keep9/short-nondb/old-short/$name" );
open( OUTPARA, ">>d:/a-keep9/short-nondb/progs/para2/$name" );
while ( defined( $line = <GETPARA> ) ) {
if ( $line =~ /<p>(.*?)<\/p>/s ) {
print OUTPARA ("$1 \n");
}
}
#close(GETPARA);
#close(OUTPARA);
}
sub gcsestudentactivitiesbusinesslocation {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/location-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub gcsestudentactivitiesbusinessstructuredecisions {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/bsd-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub gcsestudentactivitiesfinance {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/finance-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub gcsestudentactivitiesmarketing {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/marketing-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub gcsestudentactivitiespeopleatwork {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/people-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}
sub gcsestudentactivitiesproduction {
my ($pattern) = @_;
my $c = 0;
open( INNN, "d:/a-keep9/short-nondb/allphp/allphp2.php" );
while (<INNN>) {
last if /$pattern/;
}
my ( $curr, $next1, $next2, $next3 ) = <INNN>;
close(INNN);
if ( $next3 =~ /\$i\<(\d+);/ ) {
my $nn = $1;
print OUT ("<td valign='top'> \n");
for ( $c = 1 ; $c < $nn ; $c++ ) {
print OUT ( '<a href="' . $pattern
. "/production-doc"
. $c . ".zip" . '">'
. "Document$c"
. "</a><br>"
. "\n" );
}
print OUT ("</td></tr>\n");
}
}