Are you sure about that? I was cleaning up these routines and modules and thought I saw output that was unitialized that would otherwise have drawn an error.

To be honest, I'd rather have the output than the error. I can see when the data hasn't been initialized. Short of any criticisms I receive, this represents what I was trying to achieve on this thread: Typical output

I'm fascinated by quines, and wrote a couple routines that are quine-ish:

sub write_script { use Text::Template; use File::Slurp; use 5.010; my $rvars = shift; my %vars = %$rvars; my $tmpl = $vars{"code_tmpl"}; say "tmpl is $tmpl"; my $file = $vars{"script_file"}; my $text = read_file($file); my %data = ('script', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } sub write_module { use 5.010; use File::Spec; use File::Slurp; my $rvars = shift; my %vars = %$rvars; my $tmpl = $vars{"module_tmpl"}; say "tmpl is $tmpl"; my $fspecfile = File::Spec->rel2abs(__FILE__); my $text = read_file($fspecfile); my %data = ('module', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; }

They almost work, but the code tags for html can't quite pull it off, yet it gives as much of a listing as most people would be interested in.


In reply to Re^5: 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.