diff --git a/data/gengallery.pl b/data/gengallery.pl index f0e66e683a..034483612b 100755 --- a/data/gengallery.pl +++ b/data/gengallery.pl @@ -1,6 +1,6 @@ #!/usr/local/bin/perl # -# dump.pl - script to convert tab-delimited gallery db file to +# gengallery.pl - script to convert tab-delimited gallery db file to # a section of an SGML list (not a full SGML file!) for inclusion # into another SGML file where the list element pair is # already in existence. @@ -9,8 +9,14 @@ # where type is one of: commerical, nonprofit, personal # # yymmdd own comments -# ------ --- ------------------------------ +# ------ --- ------------------------------------------------ # 980311 nsj First pass +# 980312 jrf Added sorting +# 980313 nsj Wrapped file input routine with error checking + +# Setup +# Which sort program are we using? +$sort = "/usr/bin/sort"; # What gallery are we processing? $type = $ARGV[0]; @@ -23,16 +29,30 @@ if ($type =~ m/commercial/i) { } else { die "I don't understand type $type"; } -open(FOO, "sort -f $ARGV[1] |"); -while () +# Open a pipe from a unix sort of the db file (case insensitive) +if (-f $ARGV[1]) +{ + $infile = $ARGV[1]; +} else { + die "File $ARGV[1] is unreadable or does not exist"; +} + +# Open the (sorted) file +open(DBFILE, "$sort -f $infile |"); + +# Iterate through each line, throwing out those that don't +# go in this gallery. Output each entry as list elements. +while () { # We only want entries of type $type; throw the rest out. next unless m/^$type/; + # Translate out characters special to SGML (and HTML) s/&/&/g; s/) print "
  • $name -- $description
  • \n"; }; -close(FOO); +# Close the pipe like good little daemons. +close(DBFILE); diff --git a/en/gallery/gengallery.pl b/en/gallery/gengallery.pl index f0e66e683a..034483612b 100755 --- a/en/gallery/gengallery.pl +++ b/en/gallery/gengallery.pl @@ -1,6 +1,6 @@ #!/usr/local/bin/perl # -# dump.pl - script to convert tab-delimited gallery db file to +# gengallery.pl - script to convert tab-delimited gallery db file to # a section of an SGML list (not a full SGML file!) for inclusion # into another SGML file where the list element pair is # already in existence. @@ -9,8 +9,14 @@ # where type is one of: commerical, nonprofit, personal # # yymmdd own comments -# ------ --- ------------------------------ +# ------ --- ------------------------------------------------ # 980311 nsj First pass +# 980312 jrf Added sorting +# 980313 nsj Wrapped file input routine with error checking + +# Setup +# Which sort program are we using? +$sort = "/usr/bin/sort"; # What gallery are we processing? $type = $ARGV[0]; @@ -23,16 +29,30 @@ if ($type =~ m/commercial/i) { } else { die "I don't understand type $type"; } -open(FOO, "sort -f $ARGV[1] |"); -while () +# Open a pipe from a unix sort of the db file (case insensitive) +if (-f $ARGV[1]) +{ + $infile = $ARGV[1]; +} else { + die "File $ARGV[1] is unreadable or does not exist"; +} + +# Open the (sorted) file +open(DBFILE, "$sort -f $infile |"); + +# Iterate through each line, throwing out those that don't +# go in this gallery. Output each entry as list elements. +while () { # We only want entries of type $type; throw the rest out. next unless m/^$type/; + # Translate out characters special to SGML (and HTML) s/&/&/g; s/) print "
  • $name -- $description
  • \n"; }; -close(FOO); +# Close the pipe like good little daemons. +close(DBFILE);