in reply to Regex and HTML Question

If you really insist on rolling your own, call a subroutine to get the value to expand, rather than poking directly into the symbol table. You're going to be a lot happier. It'll be easier to debug templates.
my $debugtemplate = 1;

my %values = (
  foo => "Don't forget: use strict;",
  bar => "-w is your friend"
);

while ( <TEMPLATE> ) {
    s/<~([^~]*)~>/expand($1)/eg;
    print;
}

sub expand {
   my $token = shift;
   return $values{$token} if exists $values{$token};
   return $debugtemplate ? "<~$token~>" : "";
}