#!/usr/bin/perl
#
# Make a simple HTML page which has a link to each .jpeg file
#   in the current directory.
#
# MWR 2/13/2020

$debug = 1;

$output_file = "./rev_images.html";
open(OUTPUT_FILE, ">$output_file") || die("can't open file $output_file");
printf OUTPUT_FILE "<html> \n";
printf OUTPUT_FILE "<body> \n";
printf OUTPUT_FILE " \n";
printf OUTPUT_FILE "<UL> \n";



opendir(DIR, "./") || die("can't opendir dir ./ ");
while (my $file = readdir(DIR)) {
  if ($debug > 0) {
    printf " next file is %s \n", $file;
  }
  if ($file =~ /.jpeg/) {
    # okay, this is one we want to put into the output
    printf OUTPUT_FILE "<LI> <a href='./%s'> %s </a> </LI> \n", $file, $file;
  }
}

printf OUTPUT_FILE "</UL> \n";
printf OUTPUT_FILE " \n";
printf OUTPUT_FILE "</body> \n";
printf OUTPUT_FILE "</html> \n";
close(OUTPUT_FILE);



exit 0;
