You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by as...@locus.apache.org on 2000/12/28 01:49:44 UTC
cvs commit: apache-site/mirrors mirgen.pl
ask 00/12/27 16:49:44
Modified: mirrors mirgen.pl
Log:
make the thingy that generates the mirror list "a bit" more
maintainable.
Revision Changes Path
1.2 +36 -46 apache-site/mirrors/mirgen.pl
Index: mirgen.pl
===================================================================
RCS file: /home/cvs/apache-site/mirrors/mirgen.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- mirgen.pl 1997/06/14 20:06:55 1.1
+++ mirgen.pl 2000/12/28 00:49:41 1.2
@@ -2,9 +2,39 @@
#
# To generate the list of mirrors, run "mirgen.pl > index.html".
-#Content-type: text/html
-#
-print <<EOF;
+print header();
+
+my %mirrors;
+
+open(MIRRORS, "mirrors.list");
+while(<MIRRORS>) {
+ my ($type, $country, $url, $contact) = split;
+ my %entry = (
+ country => $country,
+ url => $url,
+ contact => $contact
+ );
+ push @{$mirrors{http}}, \%entry if ($type eq "http");
+ push @{$mirrors{ftp}}, \%entry if ($type eq "ftp");
+}
+
+for my $type (qw(http ftp)) {
+ my $TYPE = uc $type;
+ print qq[</P>\n<H4 ALIGN="CENTER">Apache httpd software via $TYPE:</H4>\n];
+ print qq[<P ALIGN="CENTER"><!-- Contact addresses in comments below their hosts -->\n];
+
+ for my $mirror (@{$mirrors{$type}}) {
+ my %mirror = %{$mirror};
+ print qq[<A HREF="$mirror{url}">$mirror{country}</A> - \n <!-- $mirror{contact} -->\n];
+ }
+}
+
+print footer();
+
+exit;
+
+sub header {
+return <<EOF;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
@@ -24,52 +54,11 @@
</DIV>
<H2 ALIGN="CENTER">Apache Project Mirrors<BR>Organized by DNS Country Code</H2>
-
-<!-- Contact addresses in comments below their hosts -->
-
-<H4 ALIGN="CENTER">HTTP:</H4>
-<P ALIGN="CENTER">
-<STRONG>
-EOF
-
-open(MIRRORS, "mirrors.list");
-while(<MIRRORS>)
-{
- @AR = split;
- if($AR[0] eq "http")
- {
- print <<EOF;
-<A HREF="$AR[2]">$AR[1]</A> -
- <!-- $AR[3] -->
-EOF
- }
-}
-close(MIRRORS);
-
-print <<EOF;
-</STRONG>
-</P>
-<H4 ALIGN="CENTER">Apache software via FTP:</H4>
-<P ALIGN="CENTER">
-<STRONG>
-EOF
-
-
-open(MIRRORS, "mirrors.list");
-while(<MIRRORS>)
-{
- @AR = split;
- if($AR[0] eq "ftp")
- {
- print <<EOF;
-<A HREF="$AR[2]">$AR[1]</A> -
- <!-- $AR[3] -->
EOF
- }
}
-close(MIRRORS);
-print <<EOF;
+sub footer {
+return <<EOF;
</STRONG>
</P>
@@ -81,3 +70,4 @@
</BODY>
</HTML>
EOF
+}