There's a lot to say here. The fact is, I'm still learning, and part of the learning process is re-working what you have. There isn't anything broken about this routine, for example, but writing the header to an html page is not the fancy part of this evolving toolset. As I'm now working through the Alpaca book, I want to try fancier things with language than what I can find here. Furthermore, I don't understand something until I've re-written it a few times....

sub write_header { use strict; use Text::Template; my $rvars = shift; my %vars = %$rvars; # get time my $now_string = localtime; $vars{"date"} = $now_string; my $header = $vars{"header"}; my $template2 = Text::Template->new(SOURCE => $header) or die "Couldn't construct template: $!"; my $result2 = $template2->fill_in(HASH => \%vars); return \$result2; }

I also wrote a utility script that clones the template and imports data, so that I'm not betting the whole house every time a few lines change here or there. Always curious to hear what works for other people.


In reply to Re^2: hash substitution in regex by Aldebaran
in thread hash substitution in regex by Aldebaran

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.