Need help for conveting Perl Code to a C Code

Please support our Perl advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2006
Posts: 5
Reputation: JeganathanK is an unknown quantity at this point 
Solved Threads: 0
JeganathanK JeganathanK is offline Offline
Newbie Poster

Need help for conveting Perl Code to a C Code

 
0
  #1
Mar 23rd, 2007
Hi,
I'm having a Perl Code and i want to convert it into a C Code.
I want to know is there any tool is available to do so?

If not available anybony can help me to convert??
plz mail me at nrk_jegan@yahoo.com

Regards,
Jeganathan K.
Last edited by JeganathanK; Mar 23rd, 2007 at 6:41 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,420
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 257
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: Need help for conveting Perl Code to a C Code

 
0
  #2
Mar 23rd, 2007
perlcc that comes with the perl distribution
Last edited by masijade; Mar 23rd, 2007 at 2:02 pm. Reason: typo
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 5
Reputation: JeganathanK is an unknown quantity at this point 
Solved Threads: 0
JeganathanK JeganathanK is offline Offline
Newbie Poster

Re: Need help for conveting Perl Code to a C Code

 
0
  #3
Mar 28th, 2007
Can anyone convert this perl code into C Code???:!: :!:

Code:

open(IN, "$inname");

# read rest of input file in 64K junks
while(read(IN, $buffer, 64*1024))
{
$data .= $buffer;
}
close(IN);

my @data = split(//, $data);
my $color = 0;
my $lastcolor = 0;
my $layer = 0;
my $strokes = 0;
my $points = 0;
my $pointcmd = "S";

while($count < $#data) {
my $next = ord($data[$count++]);

if (($next & ~0x07) == 0x80)
{ # pen up/down
if ($next & 0x01)
{
$pointcmd = "S";
print "DEBUG pen down POSITION $count\n" if ($debug);
}
else
{
$pointcmd = "L\nE\n";
$strokes++;
print "DEBUG pen up POSITION $count\n" if ($debug);
}

$color = (($next >> 1) + ($layer * $colorlayers)) & 0x03;
print "DEBUG pen color $color\n" if ($debug);
if ($color != $lastcolor)
{
$lastcolor = $color;
print OUT "%%Color: $color\n";
print OUT ("0 0 0", "1 0 0", "0 1 0", "0 0 1")[$color] . " RGB\n";
}
}
elsif ($next == 0x88) { # time stamp
my $timestamp = ord($data[$count++]);
print "DEBUG TimeStamp $timestamp\n" if ($debug);
print OUT "%%TimeStamp: $timestamp\n" if ($timestamp < 0x7f);
}
elsif ($next == 0x90) { ## end of layer
$layer = ord($data[$count++]);
print "DEBUG End of LAYER $layer\n" if ($debug);
die("Layer # $layer > 127") if ($layer & 0x80);
print OUT "%%EndOfLayer: $layer\n\n";
}
elsif (!($next & ~0x7f)) { ## coordinates
my ($b1, $b2, $b3, $b4) = ($next, ord($data[$count+0]), ord($data[$count+1]), ord($data[$count+2]));
$count += 3;
printf "DEBUG CHECK position $count A %02x %02x %02x %02x\n", $b1, $b2, $b3, $b4 if ($debug);
# die("MSB set in coordinate bytes") if (($b1 | $$b2 | $b3 | $b4) & ~0x7f);

my $x = $b1 + ($b2 << 7);
my $y = $b3 + ($b4 << 7);
print "DEBUG $count: x = $x / y = $y\n" if ($debug);
print OUT "$x $y " . $pointcmd . "\n";
$points++;

$pointcmd = "L";
} else {
die("unknown byte " . sprintf("0x%02x", $next) . " at position $count");
}
}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC