I have two directories, one directory contains 20 text files and the other directory contains 15 jpeg's. I need to create an html page for each text file and insert the image if one exist for that text file. BTW, the file names correspond to one another. For example, 12345.txt / 12345.jpg.
I'm pretty lost on how to go about this. My thinking so far was to convert all the text files to html and use "append_head=>$image" to insert the image above the text. This works for one file but then I would have to write another script to s/// the correct image for each html file. BTW $image = something like <img src = /home/bvolk/12345.jpg>
my $conv = new HTML::TextToHTML(); $conv->txt2html(infile=>[$text_file],
append_head=>$image,
outfile=>$html_file,
title=>"Order Guide",
mail=>1,
I'm also stuck on how to convert multiple html files using the HTML:TextToHTML module.. I tried to use FILEHANDLE but I doing something wrong... Shocker!
use strict; use warnings;
my $dir = "/home/bvolk/HP_work/text_files"; opendir (TEXT, $dir) or die "Can't open $dir: $!";
my @files = map { "$dir/$_" } grep { !/^\./ } readdir TEXT;
close TEXT;
foreach my $file (@files) {
my $READ;
unless (open $READ, "$file") {
print STDERR "Couldn't open $file for reading: $!";
next;
}
my $WRITE;
unless (open $WRITE, ">$file.tmp") {
print STDERR "Couldn't open $file.tmp for writing: $!";
next;
}
my $conv = new HTML::TextToHTML(); $conv->txt2html(infile=>[$READ],
append_head=>$image,
outfile=>$WRITE,
title=>"Order Guide",
mail=>1,
);
close $WRITE; close $READ; rename "$file.tmp", $file or die "Can't rename temp file to original: $!"; --------end
If someone could give me some advice on how to best go about this I would be greatly appreciative. Desperately need help and eager to learn.
Thanks in advance!
Brian Volk [EMAIL PROTECTED]
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>