I know that to finish this, I will need to include a blurb for each hierarchy, but there's got to be a more efficient way to code the rest of this besides the above 16 or so times. For those of you who wish to see what the final pages will look like, check them out here#!/usr/local/bin/perl -w use strict; my $file = "/export/home/limo/newsgroups"; my $newfile = "/export/home/news/newfile.html"; my $altfile = "/export/home/news/altfile.html"; my $biofile = "/export/home/news/biofile.html"; my $bizfile = "/export/home/news/bizfile.html"; my $comfile = "/export/home/news/comfile.html"; my $gnufile = "/export/home/news/gnufile.html"; my $govfile = "/export/home/news/govfile.html"; my $k12file = "/export/home/news/k12file.html"; my $micfile = "/export/home/news/micfile.html"; my $newfile = "/export/home/news/newfile.html"; my $govfile = "/export/home/news/govfile.html"; my $otherfile = "/export/home/news/otherfile.html"; my $ng = "newsgroups"; use vars qw ($line $dsc $grp $title $blurb $header $footer $head); use vars qw (%alt %bio %bit %biz %com %gnu %gov %k12 %mic %new %other +%rec %sci %soc %tal %vms); ############################################## $header = <<HEADER bunch of html here. HEADER ; ############################################## $footer = <<FOOTER more html FOOTER ; ############################################## open FILE, $file || die "$!\n"; open ALTFILE, ">>$altfile" || die "$!\n"; while ($line = <FILE>) { chomp $line; if ($line =~ /(.*?)\s+(.*$)/) { $grp = $1; $dsc = $2; if ($grp =~ /^alt/) { $alt{$grp} = $dsc; $title = "alt.* $ng";} elsif ($grp =~ /^bio/) { $bio{$grp} = $dsc; $title = "bionet.* $ng" ;} elsif ($grp =~ /^bit/) { $bit{$grp} = $dsc; $title = "bit.* $ng" ;} elsif ($grp =~ /^biz/) { $biz{$grp} = $dsc; $title = "biz.* $ng" ;} elsif ($grp =~ /^com/) { $com{$grp} = $dsc; $title = "comp.* $ng" ;} elsif ($grp =~ /^gnu/) { $gnu{$grp} = $dsc; $title = "gnu.* $ng" ;} elsif ($grp =~ /^gov/) { $gov{$grp} = $dsc; $title = "gov.* $ng" ;} elsif ($grp =~ /^k12/) { $k12{$grp} = $dsc; $title = "k12.* $ng" ;} elsif ($grp =~ /^mic/) { $mic{$grp} = $dsc; $title = "microsoft.* .$ng +" ;} elsif ($grp =~ /^new/) { $new{$grp} = $dsc; $title = "news.* $ng" ;} elsif ($grp =~ /^rec/) { $rec{$grp} = $dsc; $title = "rec.* $ng" ;} elsif ($grp =~ /^sci/) { $sci{$grp} = $dsc; $title = "sci.* $ng" ;} elsif ($grp =~ /^soc/) { $soc{$grp} = $dsc; $title = "soc.* $ng" ;} elsif ($grp =~ /^tal/) { $tal{$grp} = $dsc; $title = "talk.* $ng" ;} elsif ($grp =~ /^vms/) { $vms{$grp} = $dsc; $title = "vmsnet.* $ng" ;} else { $other{$grp} = $dsc; }}} ##################################################### $head = <<HEAD <span class="centerTopTitle">$title</span> <hr align=left width="40%"><br> HEAD ; ##################################################### $blurb = <<BLURB <p>Name a topic, and it's in here. The rules for creating an <strong>alt.*</strong> newsgroup are easier than the proced +ures in the Usenet hierarchies, so new groups appear all the time. <p>At myco, we generally don't take every new <strong>alt.*</strong> group that is created out on the net, s +o <a href="http://srv.myco.org/helpdesk/f_feedback.html">submit +a request</a> if you'd like access to an alt.* group you've heard about. <br><br> BLURB ; print ALTFILE $header; print ALTFILE $head; print ALTFILE $blurb; foreach my $key (sort keys %alt) { print ALTFILE <<ALT \<a href\=\"news\:\/\/news\.myco\.org\/$key\"\>$key\<\/a\><br> +$alt{$key}<br> ALT ; } print ALTFILE $footer;
In reply to Efficient code to auto-generate web pages by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |