Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: hash substitution in regex

by Aldebaran (Curate)
on Aug 18, 2014 at 08:10 UTC ( [id://1097811]=note: print w/replies, xml ) Need Help??


in reply to Re: hash substitution in regex
in thread hash substitution in regex

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1097811]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-20 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found