Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Running perlscript on windows sytems that don't have Perl installed

by arthas (Hermit)
on Jun 06, 2003 at 00:40 UTC ( [id://263565]=note: print w/replies, xml ) Need Help??


in reply to Running perlscript on windows sytems that don't have Perl installed

You might be better of with compiling your Perl script. Some softwares for doing this are Perl2Exe, PerlApp and perlcc. This PM node has some information about them.

Anyhow, is there a particular reason you can't perform a full Perl installation?

Michele.

Replies are listed 'Best First'.
Re: Re: Running perlscript on windows sytems that don't have Perl installed
by ozgurp (Beadle) on Jun 06, 2003 at 01:03 UTC
    I am already using PerlApp. I have a code that extracts certain type of elements from a text file. These elements have names like QUAD, CBAR, CROD. I have a while loop that reads the files line by line and extracts required info.
    while(<FH>){ if($_ =~ C B A R){ do something } if($_ =~ Q U A D){ do something } if($_ =~ C R O D){ do something } if($_ =~ C B E A M){ do something } if($_ =~ C E L A S 1){ do something } ... }
    Now the problem is I have 38 different element types and 20 files with 100 MB info in total abot 2 GB. If I have a fixed code then it takes too long to read these files. My solution was to quickly re constract my code based on user selection and run that code instead of the fixed long one. So the new script will only be looking for selected elements in the while loop. I will open a new file newcode.pl write reconstracted algorithm into that code and close it. and then run it. This will prevent the code looking for unwanted elements and significantly reduce the time spent.
    while(<FH>){ if($_ =~ C B A R){ # selected element do something } if($_ =~ Q U A D){ # selected element do something } }
    I will have an .exe file doing this (PerlApp) but I can not compile the reconstructed code with PerlApp. Because the users of this program will not have PerlApp on their machines, they will not have perl on their machines either. So how can I run this reconstructed script.
      Instead of rewriting the perl script and so forth, why not just just have a hash containing all the regexes and simply interpolate which ever one you want, i.e.
      my $regex="C B A R"; #however you choose to define it while(<FH>) { if(/$regex/o) # do something; }
      PerlApp does exactly what you want, but behind the scenes. you should look into --add to include extra modules in the exe. It extracts them in $ENV{TEMP}/PDK and sets the lib to there. (yeah this skips some detail) I really would like to see the technique you're using on this.
      One thing to note is that PerlApp and Perl2Exe dont compile your app per se. they simply put every file needed in a self-extracting wrapper. You can also embed files in the exe and use a module (sorry don't know exactly.. PerlApp.pm maybe?) to pull the files back out at runtime.

      Hope I helped!

      mhoward - at - hattmoward.org

      Sure you can have your PerlApp or Perl2Exe program "compile" another Perl-program. Just write your "new" Perl-program to a file or keep it in a scalar and then do or eval it.

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Stylistic issues aside (you don't need to name $_, you can just do if(m/C B A R/), but I digress), you could probably speed up your code if your test cases are mutually exclusive. That is to say that if 'CBAR' and 'QUAD' will never appear on the same line, you can use elsif instead of if. The elsif will short circuit, thereby eliminating a ton of pattern matches. For more speed, put the more common cases towards the top of the chain of if..elsif..elseif so that it short circuits as early as possible.

      HTH,
      thor

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-29 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found