Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Evaluate variable while using

by sectokia (Pilgrim)
on Oct 21, 2022 at 13:36 UTC ( [id://11147569]=note: print w/replies, xml ) Need Help??


in reply to Evaluate variable while using

If your intention is to build up strings that contain variables, and then later interpolate that string with the values of the variables, one way would be like this:
my $a = ''; my $str = 'Hello $a'; $a = 'Kevin'; print eval qq{"$str"}

Replies are listed 'Best First'.
Re^2: Evaluate variable while using
by chickenman (Novice) on Oct 21, 2022 at 14:00 UTC
    Thank you, that's exactly what i was looking for.
      Thank you, that's exactly what i was looking for.

      Be aware that stringy eval has some serious security implications: if you give it anything based on user input, you'll have built yourself a giant security hole, as it will happily execute any arbitrary code. I strongly recommend you use one of the many other suggestions in this thread instead.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found