#!/usr/local/perl/perl -w use strict; use HTTP::Date; ###################################################################### # # index-all.pl based on bird.pl by John Fitzpatrick, Alcatel 16/12/96 # by Michael Mirmak, Intel Corp. 03/20/04 # # Creates several index.html files for the files in question # Must be run in the same directory as the index files: # # perl index-all.pl # # Will work well if all the index files are filled out correctly. # No error checking! # # Revised 06/17/05 to add information to the HTML header # DO NOT USE : characters as part of field entries (titles, etc.) # External file insertion courtesy Neil Skinnow, WebScriptsUK ###################################################################### my ($line, $rubbish, $tablefile, $subdir, $raw); my (%authorlast, %authorfirst, %company, %title, %title_lim, %date, %file, %sorted, @sorted); my ($authorlast, $authorfirst, $company, $title, $date, $file, $notable); my ($bytitle, $byauthor, $bydate, $bycompany, $byfilename, $titlecount, $minutes); my ($previous_title, $type, %type, $startpage, $previous_file, $previous_date); #my @indexlist=; #List all files beginning with "index" my ($key,$value); my @dirlist=<*>; #List all files and directories # Have created a list of all the files # Now am going to go through each one, ignoring files in the main directory foreach $subdir (@dirlist) { next if ($subdir =~ /index/); #only look at real directories opendir(DH, $subdir); # Note that opening the directory doesn't actually chdir into it! $tablefile="table.txt"; chomp($subdir); #$subdir = ""; $line = 0; open(IN, $tablefile) or $notable=1; #die "Cannot open $tablefile"; if (!$notable) { while($line=) { chomp $line; if ($line =~ /FILE/) { ($rubbish,$file)=split(/: /,$line); $file="$file"; } if ($line =~ /TITLE/) { ($rubbish,$title{$file})=split(/: /,$line); ($title_lim{$file} = $title{$file}) =~ s/^(The )|(\[)//; } if ($line =~ /AUTHORLAST/) { ($rubbish,$authorlast{$file})=split(/: /,$line); } if ($line =~ /AUTHORFIRST/) { ($rubbish,$authorfirst{$file})=split(/: /,$line); } if ($line =~ /COMPANY/) { ($rubbish,$company{$file})=split(/: /,$line); } if ($line =~ /DATE/) { ($rubbish,$date{$file})=split(/: /,$line); } if ($line =~ /TYPE/) { ($rubbish,$type{$file})=split(/: /,$line); } if ($line =~ /#/) { #comment; do noting } } close(IN); } closedir(DH); $notable=0; } #################### # TITLE SORT #################### $titlecount=0; $bytitle="index-bytitle.htm"; open (MIF, "> $bytitle") or die "Couldn't open $bytitle!"; #top of page print MIF < Futures Subcommittee Files

Cookbook Subcommittee Files

(Sorted By Title)

Click on the column headers to resort the index.

A Minutes listing is available on a separate page

EoP #SORT BY TITLE $previous_title = ""; $previous_file = ""; $previous_date = ""; # startpage simply stops the printing of empty "previous" cell data at the top of the page $startpage = 1; #Sort first by title excluding leading "The", then by date foreach $file ( sort { $title_lim{$a} cmp $title_lim{$b} or HTTP::Date::parse_date($date{$b}) cmp HTTP::Date::parse_date($date{$a}) or $type{$a} cmp $type{$b}} keys %title ) { #Exclude administrative documents if (($title{$file} !~ /Agenda/) && ($title{$file} !~ /Minutes/)) { # have to catch cases where filenames AND titles are unequal -- for example, "IBIS Chair's Report" # if current and previous titles are different, just close up the row with the corresponding author, etc. # if the current and previous titles are the same, but the filenames and dates are different, just close up with the author, etc. # if the current and previous titles are the same and the dates are the same but the filenames are different, add in the # new file type without necessarily closing the row if (($title{$file} ne $previous_title) || (($title{$file} eq $previous_title) && ($file ne $previous_file) && ($date{$file} ne $previous_date))) { $titlecount++; if (!$startpage) { print MIF < EoP } # Tricky routine - filenames are unique but titles are not # we want the file types to appear in a new cell without generating a new row $startpage=0; print MIF <
Title Formats Authors Organization Date
$authorfirst{$previous_file} $authorlast{$previous_file} $company{$previous_file} $date{$previous_file}
$title{$file} $type{$file} EoP $previous_title = $title{$file}; $previous_file = $file; $previous_date = $date{$file}; } elsif (($title{$file} eq $previous_title) && ($file ne $previous_file) && ($date{$file} eq $previous_date)) { # title is the same as previous, just a different type from the same summit print MIF <$type{$file} EoP } } } # end of page print MIF < $authorfirst{$previous_file} $authorlast{$previous_file} $company{$previous_file} $date{$previous_file}
EoP close MIF; #################### # AUTHOR SORT #################### $titlecount=0; $byauthor="index-byauthor.htm"; open (MIF, "> $byauthor") or die "Couldn't open $byauthor!"; #top of page print MIF < Cookbook Subcommittee Files

Cookbook Subcommittee Files

(Sorted By Author)

Click on the column headers to resort the index.

A Minutes listing is available on a separate page

EoP #SORT BY AUTHOR $previous_title = ""; $previous_file = ""; $previous_date = ""; # startpage simply stops the printing of empty "previous" cell data at the top of the page $startpage = 1; foreach $file ( sort { $authorlast{$a} cmp $authorlast{$b} or $title{$a} cmp $title{$b} or HTTP::Date::parse_date($date{$b}) cmp HTTP::Date::parse_date($date{$a}) or $type{$a} cmp $type{$b}} keys %authorlast ) { #Exclude administrative documents if (($title{$file} !~ /Agenda/) && ($title{$file} !~ /Minutes/)) { # have to catch cases where filenames AND titles are unequal -- for example, "IBIS Chair's Report" # if current and previous titles are different, just close up the row with the corresponding author, etc. # if the current and previous titles are the same, but the filenames and dates are different, just close up with the author, etc. # if the current and previous titles are the same and the dates are the same but the filenames are different, add in the # new file type without necessarily closing the row if (($title{$file} ne $previous_title) || (($title{$file} eq $previous_title) && ($file ne $previous_file) && ($date{$file} ne $previous_date))) { $titlecount++; if (!$startpage) { print MIF < EoP } # Tricky routine - filenames are unique but titles are not # we want the file types to appear in a new cell without generating a new row $startpage=0; print MIF <
Title Formats Authors Organization Date
$authorfirst{$previous_file} $authorlast{$previous_file} $company{$previous_file} $date{$previous_file}
$title{$file} $type{$file} EoP $previous_title = $title{$file}; $previous_file = $file; $previous_date = $date{$file}; } elsif (($title{$file} eq $previous_title) && ($file ne $previous_file) && ($date{$file} eq $previous_date)) { # title is the same as previous, just a different type from the same summit print MIF <$type{$file} EoP } } } # end of page print MIF < $authorfirst{$previous_file} $authorlast{$previous_file} $company{$previous_file} $date{$previous_file}
EoP close MIF; #################### # DATE SORT #################### $titlecount=0; $bydate="index-bydate.htm"; open (MIF, "> $bydate") or die "Couldn't open $bydate!"; #top of page print MIF < Cookbook Subcommittee Files

Cookbook Subcommittee Files

(Sorted By Most Recent Date)

Click on the column headers to resort the index.

A Minutes listing is available on a separate page

EoP #SORT BY DATE $previous_title = ""; $previous_file = ""; $previous_date = ""; # startpage simply stops the printing of empty "previous" cell data at the top of the page $startpage = 1; foreach $file ( sort { HTTP::Date::parse_date($date{$b}) cmp HTTP::Date::parse_date($date{$a}) or $title{$a} cmp $title{$b} or $type{$a} cmp $type{$b} } keys %date ) { #Exclude administrative documents if (($title{$file} !~ /Agenda/) && ($title{$file} !~ /Minutes/)) { # have to catch cases where filenames AND titles are unequal -- for example, "IBIS Chair's Report" # if current and previous titles are different, just close up the row with the corresponding author, etc. # if the current and previous titles are the same, but the filenames and dates are different, just close up with the author, etc. # if the current and previous titles are the same and the dates are the same but the filenames are different, add in the # new file type without necessarily closing the row if (($title{$file} ne $previous_title) || (($title{$file} eq $previous_title) && ($file ne $previous_file) && ($date{$file} ne $previous_date))) { $titlecount++; if (!$startpage) { print MIF < EoP } # Tricky routine - filenames are unique but titles are not # we want the file types to appear in a new cell without generating a new row $startpage=0; print MIF <
Title Formats Authors Organization Date
$authorfirst{$previous_file} $authorlast{$previous_file} $company{$previous_file} $date{$previous_file}
$title{$file} $type{$file} EoP $previous_title = $title{$file}; $previous_file = $file; $previous_date = $date{$file}; } elsif (($title{$file} eq $previous_title) && ($file ne $previous_file) && ($date{$file} eq $previous_date)) { # title is the same as previous, just a different type from the same summit print MIF <$type{$file} EoP } } } # end of page print MIF < $authorfirst{$previous_file} $authorlast{$previous_file} $company{$previous_file} $date{$previous_file}
EoP close MIF; #################### # COMPANY SORT #################### $titlecount=0; $bycompany="index-bycompany.htm"; open (MIF, "> $bycompany") or die "Couldn't open $bycompany!"; #top of page print MIF < Cookbook Subcommittee Files

Cookbook Subcommittee Files

(Sorted By Organization)

Click on the column headers to resort the index.

A Minutes listing is available on a separate page

EoP #SORT BY COMPANY $previous_title = ""; $previous_file = ""; # startpage simply stops the printing of empty "previous" cell data at the top of the page $startpage = 1; foreach $file ( sort { $company{$a} cmp $company{$b} or $authorlast{$a} cmp $authorlast{$b} or HTTP::Date::parse_date($date{$a}) cmp HTTP::Date::parse_date($date{$b}) or $title{$a} cmp $title{$b} or $type{$a} cmp $type{$b}} keys %company ) { #Exclude administrative documents if (($title{$file} !~ /Agenda/) && ($title{$file} !~ /Minutes/)) { # have to catch cases where filenames AND titles are unequal -- for example, "IBIS Chair's Report" # if current and previous titles are different, just close up the row with the corresponding author, etc. # if the current and previous titles are the same, but the filenames and dates are different, just close up with the author, etc. # if the current and previous titles are the same and the dates are the same but the filenames are different, add in the # new file type without necessarily closing the row if (($title{$file} ne $previous_title) || (($title{$file} eq $previous_title) && ($file ne $previous_file) && ($date{$file} ne $previous_date))) { $titlecount++; if (!$startpage) { print MIF < EoP } # Tricky routine - filenames are unique but titles are not # we want the file types to appear in a new cell without generating a new row $startpage=0; print MIF <
Title Formats Authors Organization Date
$authorfirst{$previous_file} $authorlast{$previous_file} $company{$previous_file} $date{$previous_file}
$title{$file} $type{$file} EoP $previous_title = $title{$file}; $previous_file = $file; $previous_date = $date{$file}; } elsif (($title{$file} eq $previous_title) && ($file ne $previous_file) && ($date{$file} eq $previous_date)) { # title is the same as previous, just a different type from the same summit print MIF <$type{$file} EoP } } } # end of page print MIF < $authorfirst{$previous_file} $authorlast{$previous_file} $company{$previous_file} $date{$previous_file}
EoP close MIF;