#!/usr/local/bin/perl use lib "/home/pj/roads-v2.1/lib"; use Getopt::Std; require ROADS; # location of class-map file $cm="$ROADS::Config/class-map"; #print "Class-map is at $cm\n"; # subject-listings target directory $tpath="$ROADS::HtDocs/subject-listing/"; $target=$tpath."index.html"; #print "Target is $target\n"; $header=$ROADS::Config.'/multilingual/UK-English/sl-index/header'; #print "Header is $header\n"; $trailer=$ROADS::Config.'/multilingual/UK-English/sl-index/trailer'; #print "Trailer is $trailer\n"; die; # Open the class-map and slurp the info into a hash $lineCount=0; open(IN, "$cm"); while(){ $lineCount++; ($code, $title, $stem)=split(/:/, $_); chomp($stem); $mapHash{$stem}=$title; } close(IN); int($half=$lineCount/2); #print $half; @vals=values(%mapHash); #chomp(@vals); @keys=keys(%mapHash); @vals=sort(@vals); #@vals=@newvals; open (OUT, ">$target") || die "\nUnable to open $target for writing\n"; open (IN, "$header"); while(){print OUT;} close(); $toHalf=0; foreach $val (@vals){ $toHalf++; $keyCount=$toHalf-1; foreach $key(@keys){ if(-e "$tpath$key.html"){ if($val=~/$mapHash{$key}/){ #print "$key.html exists, generating link\n"; print OUT "\n

$val

"; } } } if($toHalf eq $half){ #print "\$toHalf is $toHalf and \$half is $half\n"; print OUT ' '; } } open (IN, "$trailer"); while(){print OUT;} close(); close(OUT);