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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |