#!/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";

In reply to Create HTML files using perl on the fly by sKore

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.