in reply to Re: Assigning scalars to scalar template includes
in thread Assigning scalars to scalar template includes

The code you gave me works great. What I am trying to do is: If keywords are found in <RESULTS> only then:
$main_template =~ s/%%searcresults%%/$pitem/g;
If keywords are found in <PREMIUM> only then:
$main_template =~ s/%%premiumresults%%/$premiumitem/g;
If keywords are found in both <RESULTS> and <PREMIUM> then:
$main_template =~ s/%%searcresults%%/$pitem/g; $main_template =~ s/%%premiumresults%%/$premiumitem/g;

Replies are listed 'Best First'.
Re^3: Assigning scalars to scalar template includes
by dws (Chancellor) on Jul 01, 2004 at 19:18 UTC

    What I am trying to do is: ...

    O.K., but what do you want to do with $main_template if there are no results? Leave %%searchresults%% there? Or do you want to erase it? I assume you want to erase it.

    Here's enough of a start that you should be able to figure the rest out yourself:

    # join results into a single variable; this may be empty my $results = join('', @results); # do the substitution. $main_template =~ s/%%searchresults%%/$results/g;