Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Generate files from a template with values from a list

On Fri, May 04, 2007 at 10:02:11AM +0000, zzapper wrote:
> Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote in
> news:20070504060311.GA7884@xxxxxxxxxxxxxxxxxxxx: 
> > On 2007-05-03 at 23:45 +0000, zzapper wrote:
> >> I have an html template file which contains two fields xx_ and yy_
> >> 
> >> I need to generate a number of copies of pages from this template each
> >> time replacing the fields xx_ and yy_ with values from a list.
> >> 
> >> The list contains 49 xx_ yy_ pairs eg
> >> 
> >> 11,234
> >> 15,235
> >> 21,236
> >> ..
> >> ..
> >> etc
> >> 
> >> So I want to create 49 pages each populated from one pair from the list
> Thanks Phil,
> In fact a pure Perl solution turned out to be trivial.
> 1) Put list of xx_, yy_ pairs into an array of arrays
> 2) Put template into a hereis variable
> 3) for loop,substitute,write to file, Bob's Your Aunty
> always been interested in where the shell/perl script boundary is.
I really don't think there is a clear boundary. It's a matter of which
gets the job done (for you). In this case you found that implementing
the script in Perl did the job. Somebody else might have (equally
trivially) done the same thing in zsh, Ruby, or maybe even in Monty 
Python's Flying Circus.

There are a few cases where I would argue that Perl is definately a
better choice than zsh. Equally, there are a few cases where I would say
that zsh is definately the better tool for the job. In all other cases
(that huge grey zone in between), it all depends on which one you are 
more familiar with, what mood you are in, what you had for breakfast 
and so on.

Messages sorted by: Reverse Date, Date, Thread, Author