On 4/10/06, tom arnall <[EMAIL PROTECTED]> wrote: > Is there any way to run perl - apart from apache and modperl - that avoids > having to recompile perl each time it's invoked? Specifically, I have a > script that turns a large file into a hash variable each time it is invoked > from nedit. > > Thanks, > > Tom Arnall > north spit, ca >
That depends what you mean by "compile perl". Perl itself is only recompiled when you reinstall it from source. If you mean no recompiling your code every time it's run...that's a differnt story. There are a couple of bytecode options, none of them very stable. Oliver's link would be a good place to start thinking about the compiler. also see the perlcc perldoc. That isn't going to help you keep from loading a hash, though: variables are evaluated at run time (exept in a few cases, e.g. strings that evaluate to constant values). That's what enables them to be variable. You're real question, as I take it, is "how do I reuse a hash?" for that, there are a number of different answers. One is to save the hash to a simple database. See dbmopen. Another is to significantly speed up the file read using a module like Data::Dumper or Storable that's designed for the purpose. Still another option (the one that mimics mod_perl most closely) would be to write your app as a client-server app. Put the heavy lifting of initialization into a daemon that will start once and run in the background. Which solution makes the most snese to you will depend on your particular situation: how big the data set is, whether you expect to have several instances running concurrently, etc. HTH, -- jay -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org values of β will give rise to dom!