I posted this about 2 weeks ago but it's not working so I thought I'd start fresh so everyone could see it and input.

I have a CGI created hash (%input) of parameters that are passed to this script. I want to be able to go through the hash and replace matching tokens in a template file with these values.

Example: 'http://someserver/cgi/somecall.pl?file=this.dat', I could then do a search and replace on the $page_template for $file$, where the parameter name is between the wrapper character (in this case '$').

This is what I have currently:

my $w = $input->param('wrapper'); for ( keys %input ) { $page_template =~ s/\Q$w$_$w/$input->param($_)/eg; $page_template =~ s/\Q$w\lc\_$_\E$w/$input->param(lc)/eg; $page_template =~ s/\Q$w\uc\_U$_\E$w/$input->param(uc)/eg; }

...but this is not working.

Note that I am also doing a upper and lower case replacement as well. Parameter names will be appended with a "lc_" or "uc_" depending on the template writers need.

Any help getting this to work would be greatly apprechiated as this is the only thing in my script that I have left to fix (I think) ;-p.

TIA

======================
Sean Shrum
http://www.shrum.net


In reply to Do regex using hash keys to wrapped template tokens by S_Shrum

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.