Mark Dominus on 8 Dec 2003 12:21:46 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: perl -wc


> I'm using a script that runs 'perl -wc' over my modules before they're
> checked in to CVS.  This has helped me catch quite a few errors in my
> code before I commit to CVS (including stray keystrokes and typos).
> 
> The codebase has grown (it's about 1030 [Perl] source files at this
> point) and the process of running the perl -wc now takes quite a while.  
> 
> Is there any way to perform the same operation from within a
> script/program without resorting to the fork/exec? I'd like a utility
> that could crawl the source tree testing each module to see if it
> compiles cleanly - I just want it to be fast.

I would be very surprised if the bottleneck here was the fork-exec.  I
would guess that the major cost of compiling and checking Perl code
was the compilation and the check.  If that is true, there is nothing
you can do to make it much faster.

> I've read about Safe module for compartmentalized compilation or
> execution, but I've been unable to find a set of opcodes that allows
> me to eval/compile code successfully (I think I'm missing allowed op
> codes for use or require). 

Isn't there an option for Safe that says to allow absolutely
everything?  My recollection is that Safe uses a bit vector for the
allowed op codes, and so setting the vector to all 1's should allow
everything.   Have you tried

        $compartment->deny_only();

?  

Here's another thought.  If most of the Perl source files are modules,
then make one  single file with 

        use Module_0001;
        use Module_0002;
        use Module_0003;
        ...
        use Module_1030;
        1;

and run perl -wc on that one file.

Here's another thought, perhaps the most useful:  Try something like:

        $SIG{__WARN__} = sub { die @_ };
        $^W = 1;
        for (@all_1030_modules) {
          eval { require $_ };
          if ($@) {
            # compilation of $_ generated warnings or failures
          } else {
            # it didn't
          }
        }

I hope something here was helpful.  But I expect that none of it will
be, because checking 1030 Perl source code files for errors is going
to take a lot longer than doing 1030 forks and execs.  I'd suggest
that before you look into this in more detail, you try

        time perl -nle 'for (1..1030) { system("true") }'

and see how long it takes; that's the maximum amount of time you can
save by eliminating the execs.

-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**


  • References:
    • perl -wc
      • From: "Kyle R. Burton" <mortis@voicenet.com>