I believe you will need & instead of &, if my assumption that your string is an HTML fragment is correct.
| [reply] [d/l] [select] |
Your code looks correct, although as the other reply suggests if you wish to have an ampersand displayed in a browser you should probably use the '&' entity.
Have you verified that your form input contains what you think it does? For example no trailing whitespace, etc?
| [reply] |
The problem isn't where I want to print the "&" or not but where the string matchs. See the ex;
If you do this:
my $test = "A C Test";
if($test=~s/\bA C Test\b/A&C Test/){print "<b>$test</b>";}
It will work.
But if the value is coming from something like this:
my $test_name = $in{'test_name'};
It will nor work.
That's my problem!
Tks... | [reply] [d/l] [select] |
This is why I said "Have you verified that your text contains what you think it does?".
Print it out and see!
In the code you give above, for example, you're testing against $test - but getting the input into $test_name - which isn't being used!
| [reply] |
Have you tried using chomp to remove any trailing newlines?
e.g. my $string = chomp($myinput);
| [reply] |
& is a metacharacter on the substitution side of a s/// which must be escaped with a backslash, like this: \&
see perldoc perlre for more.
Edit:
Following my own advice, I tell you not to believe my first sentence. That would be true for the sed command, but not necessarily for Perl. In some circumstances however, when you use the /e modifier, it yields true again.
Cheers, Sören
| [reply] |