XP is just a number | |
PerlMonks |
Re: Re: Changing a single quoted string into an interpolated stringby Coyote (Deacon) |
on Aug 28, 2001 at 00:42 UTC ( [id://108264]=note: print w/replies, xml ) | Need Help?? |
I posted my original question a bit too quickly.
The qq operator does exactly what I want it to do without using
an eval block. Is there any reason to use taint mode if
the code isn't going to be evaluated? Also, I am checking
the format of the argument for validity in my production code.
I just cut it out to simplify the example code.
Update: I completely fooled myself with a bug in my code. qq does not work with out doing an eval. busunsl's solution works as expected, but isn't optimal because of the taint issue and the fact that I'm actually using sprintf in my production to build a hash rather than using printf to dump the results to STDOUT. After playing with it a while, I came up with a solution that uses a translation table and a regex to convert the single quoted string to a double quoted string. Some sample code follows:
The result of running sample.pl -F %s:\t%s\n yields:
---- Coyote
In Section
Seekers of Perl Wisdom
|
|