in reply to Re: Re: Re: Do regex using hash keys to wrapped template tokens
in thread Do regex using hash keys to wrapped template tokens

My bad. Here's the long version.

I have not seen a implementation of $input->param(<red>$1</red>). I assumed it needed to be in a for loop.

I placed the code you supplied into my script (sans for loop) but see nothing happening in the final displayed result (tokens are displayed).

More specifically:

In the template file (which is a html page) there are the following tokens which are wrapped with a variable character that is defined within the script as '$' but can be overridden by passing a different value in the script call (&wrapper=somevalue):

icon -> $icon$ title -> $title$ sort -> $sort$
In my script call, I pass the following parameters:
?file=whatsnew.dat &for=Soaring &in=Area &max=10 &order=desc &sort=Date &icon=address.gif &title=Testing

Of the parameters passed, three should perform replacements. What I am getting back in $page_template after s&r is:

icon -> $icon$ title -> $title$ sort -> $sort$

...as if the search did not find matches. Since this search involves a hash, I am wondering if that is what it is looking for: CGI->HASH(...) vs the value of $input->param(...). My understanding is that the w+ (lookahead) should take care of this.

No errors are displayed.

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

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Do regex using hash keys to wrapped template tokens
by little (Curate) on Feb 14, 2002 at 12:02 UTC
    No, it didn't find the replacements I guess.
    # if called with no args param returns a list of the keys my $w = $input->param(); # here you should validate the values for the given keys # and eventually set them to default values before proceeding # $1 is just _the first succesfull match_ $page_template =~ s/\$(\w+)\$^\w/$input->param($1)/eg; $page_template =~ s/\$(\w+)\$lc_/lc($input->param($1))/eg; $page_template =~ s/\$(\w+)\$uc_/uc($input->param($1))/eg;

    Have a nice day
    All decision is left to your taste