Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 09-13-2005, 02:30 PM   #1 (permalink)
 
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  
Old 09-14-2005, 03:24 AM   #2 (permalink)
 
Super Techie

Join Date: Jan 2005

Posts: 295

gab00n

Default

Well there is something wrong with that program, 62, 000 lines of code is a big hint that it's messed up. I would suggest learning C and doing it yourself, or find another program.
__________________
\"Today\'s scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality.\" Nikola Tesla
gab00n is offline  
Old 09-14-2005, 02:34 PM   #3 (permalink)
 
Junior Techie

Join Date: Jun 2005

Posts: 94

ever_thus

Default

There's nothing wrong with the perl code; it runs fine and in such a small script I would have caught any obvious mistakes. As writing it myself in C that means converting the File module and regular expression operator to C. The point of the perlcc program is that's meant to automate that. Since perlcc is part of the official Perl distribution i would assume it's the best program for such a conversion.
ever_thus is offline  
Old 09-14-2005, 06:27 PM   #4 (permalink)
 
Super Techie

Join Date: Jan 2005

Posts: 295

gab00n

Default

I never said there was a problem with the perl code, when i said program i meant the program you were using to convert the perl code to C code. So try and find a different one, ask around or search Google. I don't know of any other good ones, also try reinstalling perlcc.
__________________
\"Today\'s scientists have substituted mathematics for experiments, and they wander off through equation after equation, and eventually build a structure which has no relation to reality.\" Nikola Tesla
gab00n is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On