#!/usr/bin/perl use warnings; use strict; #this one accounts for pics with no text file umask 0022; #do a simple glob for .txt files my @tfiles = <*.txt>; (@tfiles) = map{ $_ =~ /(.*).txt$/ } @tfiles; print "text-> @tfiles\n"; #assume photos are in subdir pics/* #do a simple glob for .jpg files my @jfiles = ; (@jfiles) = map{ $_ =~ /pics\/(.*).jpg$/ } @jfiles; print "jpg-> @jfiles\n"; #now find which pics don't have a txt file my %h; # Initialise the hash using a slice @h{@tfiles} = undef; @jfiles = grep {not exists $h{$_}} @jfiles; print "stray jpg-> @jfiles\n"; #now push the stray photo onto the end of the @tfiles push @tfiles,@jfiles; print "all html-> @tfiles\n"; foreach my $file (@tfiles) { open(HH, "> $file.html") or warn "$!\n"; my $text = ''; #print headline print HH<

$file

EOH #print jpg if exists if( -e "pics/$file.jpg"){ print HH<[$file.jpg] EOI }else{ print HH<[No Image Available] EOI } #print text if exists if( -e "$file.txt"){ open(TH, "< $file.txt") or warn "$!\n"; read( TH, $text, -s TH ); close TH; print HH<
$text
EOT } print HH< EOHTML close HH; }