Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Using vars in a var

by davido (Cardinal)
on Nov 02, 2022 at 16:25 UTC ( [id://11147924]=note: print w/replies, xml ) Need Help??


in reply to Using vars in a var

There is nothing magical about the database portion of this; it's just a distraction. If $htmlvar contains what you want it to, it will contain that whether you print is value or UPDATE it into a text-based field in a database using placeholders and execute(). So set up a test that eliminates the confusion of the database.

my $price = "50"; my $htmlvar_qq = "<li>The price is \$$price</li>"; my $htmlvar_q = '<li>The price is \$$price</li>'; print "$_\n" for $htmlvar_qq, $htmlvar_q;

The output will be:

<li>The price is $50</li> <li>The price is \$$price</li>

In response to your question someone suggested that you probably were using single quotes. You followed up by stating that you tried with double quotes also, and still had the problem. If that's the case, please provide code that exhibits the incorrect behavior while printing to STDOUT rather than updating into a database. If it really only happens when updating into the database, please provide an example where you are printing to STDOUT and updating into the database, and getting something different in the database than what you see on STDOUT.


Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147924]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2025-12-06 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (85 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.