mickey has asked for the wisdom of the Perl Monks concerning the following question:
I have a subroutine that is assembling strings from the contents of some hashes. I'd like to be able to pass the subroutine a single-quoted string that has variable names in it, and interpolate the variables within the context of the subroutine, sort of like using a format string for sprintf().
For instance, I want to be able to compose multiple strings like this: 'Foo_bar($a,$b,$c,,$d,,$e)'
which, because they're single-quoted, contain the literal $a etc. references, and then pass them to a subroutine that defines $a, $b, $c, $d, and $e, and returns the original string with those variables interpolated.
I'm hoping this makes sense to someone!
If so, what would be the correct syntax to use in the subroutine to evaluate and interpolate the string?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: interpolating preset strings in variable context (or something like that)
by ihb (Deacon) on Mar 14, 2005 at 21:36 UTC | |
|
Re: interpolating preset strings in variable context (or something like that)
by Mugatu (Monk) on Mar 14, 2005 at 21:29 UTC | |
by mickey (Acolyte) on Mar 14, 2005 at 22:47 UTC | |
by Mugatu (Monk) on Mar 14, 2005 at 23:10 UTC | |
|
Re: interpolating preset strings in variable context (or something like that)
by Zaxo (Archbishop) on Mar 14, 2005 at 21:15 UTC | |
by mickey (Acolyte) on Mar 14, 2005 at 21:26 UTC | |
by Anonymous Monk on Mar 15, 2005 at 04:50 UTC |