Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Intermixed perl?

by jbert (Priest)
on Nov 09, 2007 at 16:37 UTC ( [id://649935]=note: print w/replies, xml ) Need Help??


in reply to Intermixed perl?

I think Text::Template does exactly this.

You can embed perl code in your templates, escaped in the way you choose.

Replies are listed 'Best First'.
Re^2: Intermixed perl?
by halley (Prior) on Nov 09, 2007 at 17:48 UTC
    I'm gathering that bschmer is feeding the commands to that interpreter, and the perl code should be able to make decisions on the RESULTS of those individual commands. (See the == FAIL case he illustrates.) Thus, the behavior or selection of later commands can be adjusted based on the results in earlier tests. Correct me if I'm wrong, but pre-authoring a more complicated script file ahead of time with a simple template tool won't help there.

    --
    [ e d @ h a l l e y . c c ]
    This is my 1000th posting to PerlMonks.

      No, you're right. But I don't see how the problem as posed makes sense since he wants to add syntactic constructs (e.g. close brace }) at runtime (i.e. post-parse).

      So I'd guess I'd solve his specific problem by adding some plugin capability to his interpreters, so I could do something like MYEMPLOYER_APP_PLUGINS=Foo,Bar and then the Foo and Bar plugins get called at various stages of command and argument processing.

      This would require defining an API for the plugins in terms of what they could inspect and what they could change.

      So this is work. And hence sucks, and this is why little languages (DSLs) suck unless they are embedded within a more powerful general purpose language (so you can escape to the big language when you need to). Otherwise you find yourself re-inventing loops, conditionals, I/O etc in your little language over time.

      So I guess really I'd write a converter to make all of these cmd files become perl and then just embed perl. It could be fairly mechanical (he already has the parsers):

      command1({param1 => "value1", param2 => "value2"});
      and then pre-load a per-interpreter module which provides functions (command1 etc) which must also already exist.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://649935]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found