http://qs321.pair.com?node_id=651829
Category: HTML Utility
Author/Contact Info sKore
Description: Create HTML files using perl on the fly.

#!/usr/bin/env perl 
use warnings; 
use strict; 
use Data::Dumper; 

my $file="MySpace.html"; 
my $cmdString = "/tmp/"; 
chdir($cmdString)|| die "Error: could not '$cmdString'"; 
if (-e $file) #if the file exists 
{ 
$cmdString="rm $file"; 
system($cmdString)==0 or die "Error: could not '$cmdString'"; 
} 
open(my $FILE, ">>$file") or die "Cannot open $file: $!"; ## >> means 
+append to the end of file. 
my $fontColor="D2L"; 
my $empNo=43432; 
my $empName="Marconi"; 
my $empDesg="Managed Director"; 
my $empSal="59999.99"; 
print $FILE "<HTML>\n";
print $FILE "<table width=\"100%\">\n"; 
print $FILE "<tr><th colspan=\"4\" class=\"H25H\">HelloWorld</th></tr>
+\n"; 
print $FILE "<tr><th class=\"H25L\">Emp#</th><th class=\"H25L\">Name</
+th><th class=\"H25L\">Designation</th><th class=\"H25L\">Salary</th><
+/tr>\n";

If ( $empDesg == "Managing Director") 
{ 
$fontColor="W30L"; 
} 
print $FILE "<td class=$fontColor>$empNo</td><td class=$fontColor>$emp
+Name</td><td class=$fontColor>$empDesg</td><td class=$fontColor>$empS
+al</td></tr></table>\n";

print $FILE "<br><br>\n"; 
print $FILE "<head><META http-equiv=\"Content-Type\" content=\"text/ht
+ml; charset=UTF-8\"><style type=\"text/css\">table {border: 1 solid b
+lack; border-collapse: collapse; } th {border: 1 solid black; width: 
+20%; text-align: left; background: #B8B8B8} td {border: 1 solid black
+; width: 80%} .H25H {border: 1 solid black; width: 25%; text-align: c
+enter} .H25L {border: 1 solid black; width: 25%; text-align: left} .D
+2L {border: 1 solid black; width: 25%; text-align: left; background: 
+#DDDDDD} .W30L {border: 1 solid black; width: 25%; text-align: left; 
+background: #DDDDDD ; font-size : 12pt; font-weight: bold; color:red}
+</style></head></html>\n";

close($FILE); 

print "Your html has been created";