Thread: perl to C
View Single Post
Old 09-13-2005, 01:30 PM   #1 (permalink)
ever_thus
 
Junior Techie

Join Date: Jun 2005

Posts: 94

ever_thus

Default perl to C

I compiled a perl script to C using activeState perl's c compiler (that's perlcc, the optimized c compiler, not perlc). The result is ~62,000 line file full of monstrosoties like { (OP*)&binop_list[727], 0, NULL, 15, 0, 65535, 0xb6, 0x3, (OP*)&padop_list[584] } and which won't compile under borland c/c++ compiler. The script itself is simple enough, as you can see below.

use File::Find;

sub wanted{
if (/\.$exts_patt\Z/){
open FILE, $_;
while (<FILE>){$num++;}
close FILE;
}
};

$num = 0;
print "Enter the directories and/or files to count\n";
$dirs = <STDIN>;
print "Enter the extensions of the files to count\n";
$exts_list = <STDIN>;
$exts_patt = (join '|', split (' ', $exts_list));
find \&wanted, split (' ', $dirs);
print $num;

I've never converted perl to C before (the ultimate objective here is to produce a binary), so any help would be appreciated.
ever_thus is offline