[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: invoking wml in current perl interpreter?

Hello Jim Hebert, in a previous mail you wrote:

> Sorry if this is a little off topic... It's marginal, but I know RSE has
> already hurdled this when running each pass out of the control script.
> I have a perl script that is going to do some stuff, then run wml and send
> the output to the stdout. Right now it does something cheesy like "print
> `wml ...`."
> I'd like to speed this up somewhat by using the current perl interpreter.
> It's the last thing the script does, so I don't even need to worry about
> trashing anything in the variable namespaces...
> I tried reading the source but wasn't sure what I was looking for in the
> first place. =)

Hmmm... I think you can directly replace the 

   print `wml $args`;

command with

    @ARGV = ();
    while ($args) {
        redo if $args =~ s|^\s*(-[a-zA-Z0-9]\S+)|push(@ARGV, $1), ''|iges;
        redo if $args =~ s|^\s*(-[a-zA-Z0-9])|push(@ARGV, $1), ''|iges;
        redo if $args =~ s|^\s*"([^"]*)"|push(@ARGV, $1), ''|iges;
        redo if $args =~ s|^\s*'([^']*)'|push(@ARGV, $1), ''|iges;
        redo if $args =~ s|^\s*(\S+)|push(@ARGV, $1), ''|iges;
        redo if $args =~ s|^\s+$|''|iges;
    require '/path/to/wml';

I've not tried it, but theory says it should work ;-). If it doesn't work then
extract WML's dosource() function and use this one in your program.

                                       Ralf S. Engelschall
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com