Suppose you have to work on a project that includes some scripting language that is horribly crippled compared to Perl. For example, you are using FooScript with your graphics application, and you discover that FooScript does not have a facility for generating 'random' numbers.

This little script hacks together a FooScript file, saves it to a temporary location and runs it, all from within Perl. The neat part is, you fill in the missing features by passing them in from Perl. Moreover, because Perl allows you to use non-standard quotation delimiters, you do not have to worry about using a lot of ugly backslash and escaping characters. Your Perl looks like intelligible Perl, and your FooScript looks like intelligible FooScript.

### <region-file_info> ### main: ### - name: tryRunTempScript001 ### desc: use perl to generate a script in another language ### date: Thu Sep 16 09:09:11 2004 ### </region-file_info> ### begin_: init perl script use strict; use warnings; use lib "c:/MyPerlStuff/lib"; use MyScriptUtils; ### begin_: main perl code my $bin = "c:/FooScript/FooScript.exe"; my $ext = '.foos'; my $dd = {}; $dd->{random} = int(rand(200)); MyScriptUtils::RunTempScript(TempScript($dd), $bin , $ext); ### begin_: subroutine to define the FooScript script code sub TempScript { my $dd = shift; my $strOut = "" ### İİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİ ### İİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİ .qİ ### FooScript script language does not allow us to generate ### random numbers, so we let perl fill in the missing ### features. FooPrint("The random number is: İ.$dd->{random}.qİ") İ; ### İİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİ ### İİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİİ return($strOut); }###end_sub

In reply to Fill in the missing features from your other script language by dimar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.