Nichodemus has asked for the wisdom of the Perl Monks concerning the following question:
I am relatively new to Perl -- I figure there must already be a way to do this without writing my own custom subroutine. Here's my question:
How can I force a scalar variable to be re-interpolated?
For example, lets say that this line of code:
print $raw;
returns:
fred has $color eyes
What I want to be able to do is later set $color to equal "blue." And then have:
$parsed = # ??? something to re-interpolate $raw
print $parsed; # I get the text "fred has blue eyes"
Anyone have any ideas?
-Nich
How can I force a scalar variable to be re-interpolated?
For example, lets say that this line of code:
print $raw;
returns:
fred has $color eyes
What I want to be able to do is later set $color to equal "blue." And then have:
$parsed = # ??? something to re-interpolate $raw
print $parsed; # I get the text "fred has blue eyes"
Anyone have any ideas?
-Nich
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re-Interpolating a Scalar (a string)
by cmeyer (Pilgrim) on Jul 29, 2005 at 18:27 UTC | |
Re: Re-Interpolating a Scalar (a string)
by jeffa (Bishop) on Jul 29, 2005 at 18:49 UTC | |
Re: Re-Interpolating a Scalar (a string)
by Nichodemus (Initiate) on Jul 29, 2005 at 18:28 UTC | |
by friedo (Prior) on Jul 29, 2005 at 18:34 UTC | |
by Joost (Canon) on Jul 29, 2005 at 18:33 UTC |
Back to
Seekers of Perl Wisdom