hide random home http://www.byte.com/art/9603/sec10/vprtabs.pl (PC Press Internet CD, 03/1996)

# vprtabs.pl, Jon Udell (jon_u@dev5.byte.com), BYTE, Copyright 1996 # # Assume $DocRoot/$DocDir contains HTML files with this format: # # # # # # # Then this command: # # perl vpr.pl # # builds two sets of tabbed HTML indexes into those files. One series # has the names compall1.htm .. compallZ.htm, the other is prodall1.htm .. # prodallZ.htm. # # (At http://www.byte.com/vpr/vpr.htm you can see these tabbed indexes in use.) $DocRoot = '/web/vpr'; $DocDir = 'vpr'; $typenames{'prod'} = "by product/technology"; $typenames{'comp'} = "by company"; opendir(DIR, "$DocRoot/$DocDir") || die "Can't open $DocRoot/$DocDir"; @vprs = grep (!/^\.|^\.\./,sort readdir(DIR)); foreach $vpr (@vprs) { $metacomp = $metaprod = ""; open(VPR, "$DocRoot/$DocDir/$vpr") || die "Can't open $DocRoot/$DocDir/$vpr"; while() { if ($. < 5) { if ($metacomp eq "") { $metacomp = &GetMeta($_,"comp"); } if ($metaprod eq "") { $metaprod = &GetMeta($_,"prod"); } } } ($lmetacomp = $metacomp) =~ tr/A-Z/a-z/; ($lmetaprod = $metaprod) =~ tr/A-Z/a-z/; push(@comp,$lmetacomp . '~' . $metacomp . '~' . $metaprod . '~' . $metadate . '~' . $vpr ); push(@prod,$lmetaprod . '~' . $metaprod . '~' . $metacomp . '~' . $metadate . '~' . $vpr ); } print "Content-type: text/html\n\n"; print "vpr admin"; print ""; print "
Updating..."; @comp = sort @comp; @prod = sort @prod; &BuildToc("comp","Complete",@comp); &BuildToc("prod","Complete",@prod); print "
Done updating."; print "

Back to the Virtual Press Room"; print ""; closedir(DIR); sub BuildToc { local($which,$descrip,@view) = @_; ($v1_1, $v1_2, $v1_3, $v1_4, $v1_5) = split(/~/,$view[0],5); if (($which eq "comp") || ($which eq "prod")) { $nav = ""; foreach $item (@view) { ($junk,$first, $second, $third, $file) = split(/~/,$item,5); ($nav2 = substr($first,0,1)) =~ tr/a-z/A-Z/; $nav2 =~ s/[0-9]/1/; # print LOG "nav $nav nav2 $nav2\n"; if ($nav ne $nav2) { $nav = $nav2; $toc = $which . "all" . $nav; close TOC; open (TOC, ">$DocRoot/$toc.htm"); print TOC "$descrip press releases $typenames{$which}\n"; print TOC &StdHdr(1); print TOC "

$descrip press releases $typenames{$which}


"; print TOC "
"; for (1,A..Z) { if ($nav ne $_) { $s = sprintf (" $_ ", $which, $_); print TOC $s; } else { print TOC "  $nav  "; } } #endfor print TOC " "; print TOC "

"; } #endif print TOC "
$first, $second, $third\n"; } #endforeach } #endif print TOC "
\n"; } #endsub sub GetMeta { local($line,$meta) = @_; if ( /(name=$meta)( content=)(.*)>/ ) { $ret = $3; } else { $ret = ""; } return $ret; } sub StdHdr { ($tBackground) = @_; $hdr = "\n"; if ($tBackground ="[unarchived-media]" 1) { $hdr = $hdr . "\n"; } else { $hdr = $hdr . "\n"; } $hdr = $hdr . "Home\n"; $hdr = $hdr . "Articles\n"; $hdr = $hdr . "Benchmarks\n"; $hdr = $hdr . "BYTE\n"; $hdr = $hdr . "Web\n"; $hdr = $hdr . "VPR\n"; $hdr = $hdr . "
"; $hdr = $hdr . "\n\n"; return $hdr; }