tariqahsan has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to do something like -
The input file has the following text string#!/usr/local/bin/perl $val = '123'; open (FILE), "input") || die "Can't open for reading: $!\n"; while ( defined ( $_ = <FILE> ) ) { $string = eval { $val }; print "<$val>\n"; }
input:
test_string_$val
Expecting $string to be - test_string_123
Any suggestion?
janitored by ybiC: Balanced <code> tags around code snippet
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to evaluate a variable in a text string
by Roy Johnson (Monsignor) on Mar 28, 2005 at 21:01 UTC | |
by tariqahsan (Beadle) on Mar 28, 2005 at 21:12 UTC | |
|
Re: How to evaluate a variable in a text string
by RazorbladeBidet (Friar) on Mar 28, 2005 at 20:52 UTC | |
by tariqahsan (Beadle) on Mar 28, 2005 at 20:58 UTC | |
by merlyn (Sage) on Mar 28, 2005 at 21:00 UTC | |
by tlm (Prior) on Mar 28, 2005 at 22:48 UTC | |
|
Re: How to evaluate a variable in a text string
by dragonchild (Archbishop) on Mar 28, 2005 at 20:58 UTC |