Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Use single perl instance multiple times (http://www.velocityreviews.com/forums/t907972-use-single-perl-instance-multiple-times.html)

mseele 08-01-2008 12:32 PM

Use single perl instance multiple times
 
Hi,

i have to "parse/compile" lot's of perl files (as fast as possible)
and work with the output (...Can't locate XYZ.pm in @INC (@INC
contains: XYZ) at - line 7. BEGIN failed--compilation aborted at -
line 7....).

For now i iterate over the files, create a new perl process for every
file (perl -c -W -Mstrict -I XYZ) and write the bytes of the current
file into the process.
But it is very expensive to start a new perl process for every file to
parse.

Is it possible to use only one perl process for parsing multiple perl
files?
I mean: open only one perl process, write in the bytes of a file, read
the output, "reset" the perl process (change @inc...), write in the
bytes of the next file, read the output, "reset" the perl
process...and so on till all files will be parsed/compiled. Then exit
the perl process. Is this possible?
What do i have to "reset/new initalize" after one file is processed?
Only the @INC or more?
How can i tell the perl process that one file is fully written to the
input stream and the parser/compiler should write the output to the
output stream?

Thanks,
Michael

Dr.Ruud 08-01-2008 02:32 PM

Re: Use single perl instance multiple times
 
mseele schreef:

> Is it possible to use only one perl process for parsing multiple
> perl files?


Not without side effects, but maybe good enough:

package JEQVCHSAFCUDFNDGSADKFFH;

for $file (@files) {
eval {
require $file;
1;
}
or do {
my $err = $@;
printf STDERR "%s\n", $err;
};
}

Next progress would be forking suicidals, I suppose.

Alternative approaches:
for f in *.pm ; do perl -Mstrict -wc $f ; done 2>&1 |grep -vP "\.pm
syntax OK$" |less
for f in *.pm ; do perl -Mstrict -wc $f 2>&1 |grep -vP "\.pm syntax
OK$" ; done |less

--
Affijn, Ruud

"Gewoon is een tijger."



All times are GMT. The time now is 11:40 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57