Re: variable interpolation and file read



"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
.



Relevant Pages

  • Re: OT: Quick Linux question (fairly urgent)
    ... The name didn't ring a bell (people kept alt.digitser secret from me) so ... This means if I change the page template, ... one file and re-run the "make site" Perl script again. ... was this routine outputted static HTML that I could host anywhere -- ...
    (uk.games.video.misc)
  • Re: Using a space in the username on LHS in virtusertable?
    ... > Thanks for your advice, ... > The grep gives: ... > (I removed the -o and rebuilt sendmail.cf, ... key/value separator e.g. tab [Perl script is not necessary]. ...
    (comp.mail.sendmail)
  • Re: Opening .dat file in perl
    ... > Thanks all for the past help ... > Can someone advice me on how i can open .dat file in perl script? ...
    (perl.beginners)
  • calling a server-side perl script from within VBA
    ... I need to call a server-side perl script provided by someone else from ... within my VBA code (in a Word template). ...
    (microsoft.public.word.vba.general)
  • Re: Opening .dat file in perl
    ... > Thanks all for the past help ... > Can someone advice me on how i can open .dat file in perl script? ...
    (perl.beginners)