I get a bunch of text from an external source, storing it in a variable, and then display this variable as part of a larger block of HTML. I need to display it as it is, and the dollar signs give me problems.
Here's the setting:
# get the incoming text my $inputText = "This is a $-, as in $100. It is not a 0."; print <<"OUTPUT"; before-regex: $inputText OUTPUT
In real life, those print blocks are much larger chunks of HTML with variables included in it.
I tried to avoid the dollar sign using s/\$/\$/g , because I understand that the first \$ does the re-expression, so it searches for $ , and the second \$ is what is inserted and then exits Perl, so that it just displays $ . But I canβt make it work.
Here is what I get:
before-regex: This is a 0, as in . It is not a 0. after-regex: This is a 0, as in . It is not a 0.
And here is what I want to see:
before-regex: This is a 0, as in . It is not a 0. after-regex: This is a $-, as in $100. It is not a 0.
Googling leads me to this question . When I try to use an array and for a loop in the response, it has no effect.
How can I get the output of a block to display a variable exactly as it is?
source share