Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How to evaluate a variable in a text string

by RazorbladeBidet (Friar)
on Mar 28, 2005 at 20:52 UTC ( [id://442951]=note: print w/replies, xml ) Need Help??


in reply to How to evaluate a variable in a text string

You are eval'ing $val instead of eval'ing $_

I'm assuming the rest isn't really your code (or it would be failing) so I won't say anything about that.

HTH!
RBB
--------------
"But what of all those sweet words you spoke in private?"
"Oh that's just what we call pillow talk, baby, that's all."
  • Comment on Re: How to evaluate a variable in a text string

Replies are listed 'Best First'.
Re^2: How to evaluate a variable in a text string
by tariqahsan (Beadle) on Mar 28, 2005 at 20:58 UTC
    Thanks for your reply
    My mistake in typing up the code snippet
    It is actually -

    $string = eval { $_ };
    print "<$string>\n";

      It looks like you are confusing the "string form" of eval with the "block form". Try perldoc -f eval to get the full story, and then merlyn's comment may be clearer. To do what you want to do, you need something like

      $string = eval qq("$_");
      where $_ contains your 'test_string_$val'. But as Roy already pointed out, this may not be a very wise thing to do in the first place.

      the lowliest monk

Log In?
Username:
Password:

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

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

    No recent polls found