Re: variable interpolation and file read
- From: Sherm Pendley <sherm@xxxxxxxxxxx>
- Date: Wed, 30 Nov 2005 15:54:11 -0500
"jkatz@xxxxxxxxxxxxxxxx" <jkatz@xxxxxxxxxxxxxxxx> writes:
> In fact efficency isn't a big issue here--the input files aren't very
> big. However the contents of $line can't be known by the perl script
> beforehand, only the names and values of the variables.
Reading between the lines a bit, it sounds like what you're looking for is
a "template" library. These work sort of like the old "mad-lib" games. You
create a template with placeholders in it, and then the template library
reads that and fills in the proper values.
There are many such libraries available in CPAN- search for "template" at
<http://search.cpan.org>.
My own favorite is the venerable Text::Template, although that's largely a
matter of intertia on my part. I tried it out early on (I think it was the
first such module on CPAN), and it's never pissed me off enough that I've
felt the need to look at alternatives.
> I think however that what you suggests implies that I should read
> $line, split on either side of $myvalue and then eval
> $myvalue. Am I understanding you correctly?
A word of advice: Before you consider taking PG's advice on *anything*, you
might want to review her posting history here.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
.
- Follow-Ups:
- Re: variable interpolation and file read
- From: Purl Gurl
- Re: variable interpolation and file read
- References:
- variable interpolation and file read
- From: jkatz@xxxxxxxxxxxxxxxx
- Re: variable interpolation and file read
- From: Purl Gurl
- Re: variable interpolation and file read
- From: jkatz@xxxxxxxxxxxxxxxx
- variable interpolation and file read
- Prev by Date: Re: variable interpolation and file read
- Next by Date: Re: variable interpolation and file read
- Previous by thread: Re: variable interpolation and file read
- Next by thread: Re: variable interpolation and file read
- Index(es):
Relevant Pages
|