tags:

views:

152

answers:

5

Is there a way to save a compiled version of my perl scripts?

Or a way to do a JavaScript style compile where you just remove comments, whitespace, etc?

A: 

If you're doing this for fun you might want to check out parrot vm

If not.. see my comment ;)

Øyvind Skaar
Perl 5 does not run on Parrot.
daxim
It is not *just* for fun :)
cjavapro
yeah, yeah.. I know it's bad.. was just reluctant to repeat my f# comments .. :)
Øyvind Skaar
A: 

You could use PPI to strip out comments and POD.

Alan Haggai Alavi
This probably has an insignificant effect on compile time though.
brian d foy
A: 

Perl::Squish is the "minifier" you're looking for. Caveat: It's not going to help you at all. You're trying to optimize on the wrong end.

tsee
+5  A: 

You're trying to optimize in the wrong place. If you are running scripts in a web/cgi environment, there is no need to take a compile hit every time the script is executed. The scripts should be running persistently, which you can do with Apache mod/perl, FastCGI, or a number of newer technologies and frameworks such as Plack and Catalyst. If you are more specific about your needs, you will discover that there are a number of options available to you.

Ether
+1  A: 

Do you realize that Javascript is minified to save bandwidth, not startup time or runtime? And that the practice of minifying Javascript started in the times of dialup connections?

Sure, there was a time where interpreted programs were often minified like that, but back then typical CPUs were Z80s and 8086's running at 4-8 MHz, and using loads of cycles to execute a single instruction. To show: my Athlon XP-M 2400 is ~10,000 times faster than my 8MHz 8086 for CPU-bound programs.

ninjalj