in reply to write html code with perl

Don't forget the usefulness of interpolated heredocs '<<' in generating html. See heredocs
#!/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 = <pics/*.jpg>; (@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<<EOH; <html> <BODY TEXT="#FFCCCC" BGCOLOR="#000000"> <center><h1>$file</h1></center> EOH #print jpg if exists if( -e "pics/$file.jpg"){ print HH<<EOI; <center><IMG SRC="pics/$file.jpg" alt="[$file.jpg]"></center> EOI }else{ print HH<<EOI; <center><IMG SRC="" alt="[No Image Available]"></center> 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<<EOT; <center> <pre> $text </pre> </center> EOT } print HH<<EOHTML; </body> </html> EOHTML close HH; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh