Red_Dragon has asked for the wisdom of the Perl Monks concerning the following question:
I petition you today on a matter beyond my novice ability. What I am trying to do may not even be possible, but here goes, see bolded text for the actual question.
As a part of processing, these variables get populated early in the process
Later in the process, when writing to the logfile, this line of text gets retrieved from a message table and is placed in variable $text$a_test="1"; $b_test="the RTE";
$text='titl=This is test $ma_test of $mb_test broadcasting system';
Attempting to populate variables in retrieved string with those already defined and populated earlier in the process
Iteration 1 prints "result: 1"$start=1; while (index($text,'$',$start) > 0) { $dsign=index($text,'$',$start); $blank=index($text,' ',$dsign); $w=substr($text,$dsign,($blank-$dsign)); ${(substr($w,1,length($w)-1))}=${(substr($w,2,length($w)-2))}; $start = $blank += 1; print " result: ${(substr($w,1,length($w)-1))}\n"; }
Values of resolved variables
print "ma_test: $ma_test\n";
prints out ma_test: 1
print "mb_test: $mb_test\n";
prints out mb_test: the RTE
Create and populate variable $titl with the remaining text in the string
looking for this: This is test 1 of the RTE broadcasting system${(substr($text,0,4))}=substr($text,5,length($text)-5); print " output: $titl\n";
Is it possible to resolve the variables in the text string to the values in $ma_test and $mb_test?
Thank you for any consideration
R_D
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Resolving Imbedded Variables
by davidrw (Prior) on Nov 07, 2005 at 17:41 UTC | |
|
Re: Resolving Imbedded Variables
by sauoq (Abbot) on Nov 07, 2005 at 17:44 UTC | |
by Roy Johnson (Monsignor) on Nov 07, 2005 at 18:03 UTC | |
|
Re: Resolving Imbedded Variables
by Tanktalus (Canon) on Nov 07, 2005 at 22:12 UTC | |
|
Re: Resolving Imbedded Variables
by donarb (Beadle) on Nov 07, 2005 at 17:35 UTC | |
by davidrw (Prior) on Nov 07, 2005 at 17:42 UTC | |
|
Re: Resolving Imbedded Variables
by pajout (Curate) on Nov 07, 2005 at 17:48 UTC |