[DCPM] To quote or not to quote.

Steve Marvell steve at devon-it.co.uk
Fri Jul 1 02:49:23 PDT 2005


Neil Williams wrote:
> I'm using Perl to parse some XML and generate C source code, including the 
> Makefile.am, configure.in, autogen.sh, *.c, *.h and ChangeLog.

That's disgusting!

> Naturally, I want to keep the code in the templates in sync with the
> code in the real project. However, I do NOT want to have to include
> placeholders in the REAL project. The places where the template uses
> modified strings are not predictable in a manner that would suit a
> regexp.

I'm losing it, is there a simple example?

> Whilst some files are 100% generated, there are only small changes
> required to certain files - the name of the final program, copyright
> notices, names of the objects being used in the template - so I've
> got some files that are 10k of unchanged text with only maybe a
> dozen lines changing.

And you presently do this by hand?

> Or should I save the unchanging code to snippet files that are
> opened by the script? I was hoping to avoid that in the hope that I
> could package a single script file instead of lots. If I'm going to
> use external snippet files, I'd need a way to use the same files in
> PHP too. (The PHP scripts receive input from HTML forms, cache the
> results in a MySQL table and then generate the final code. The perl
> parses the XML and generates the code from that, caching in RAM.)

Yes, an example please.

> 1. How does a perl script accept command-line arguments? (your-name, email, 
> prefix, output-dir etc.)

@ARGV? GetOpt?

> 2. once this is done, what's the easiest way to execute the
> ./autogen.sh with  parameters to start the build from within the
> perl script that generated the code? Can the one command include the
> make? (no need for make install as these are example / test
> programs). 

Exec is proably what you need, if it's the last thing you
do. Otherwise, I'd be interested in what you want to do with return
code, STDOUT and STDERR.

Steve


More information about the Devoncornwall-pm mailing list