I built a search feature on my wife's website, and I decided in the search function at the beginning, which it does not matter where because of how I did it, I had to add a variable in a hash (
$in{highlight_text} = $_query;) Where
$_query = param("q"); (Set just above this variable).
The hash (
%in) is created at the beginning of the 'system' by cgi-lib (
ReadParse(\%in)) and so I am just 'adding' a variable to it.
Now all the 'page content' is in a variable, let's call it
$_page_content_var so at the end, just before I print it to the page, I am doing this:
my $__highlight_to_switch = qq~<font class="highlight">$in{highlight_t
+ext}</font>~;
$_page_content_var =~ s/$in{highlight_text}/$__highlight_to_switch/eg;
Now my problem is that since it's a 'search' function, I have a link with the query text in there something like this: <a href="http://www.mydomain.com/index.cgi?pg=search&q=$_query"> since
$_query contains the text that I am searching for, it will inadvertantly 'switch' the q=$_query part of the text with the <font... text.
Is there a way to make this not do that? I don't want it to change stuff inside of html tags, just everything else on the page, so that it's highlighted for the end user to see the 'stuff' they searched for.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.