in reply to porting C code to Perl
haukex and syphilis have already provided some good answers but I thought that I would point out some things that I didn't see mentioned.
Perl's int is not the same as C's floor(). What you want is POSIX::floor. It has the identical behavior as C's floor().
Perl has a pre-decrement just like C.
# for(int i = len; i > 0; --i) { # C # for(my $i = $len; $i > 0; $i--){ # incorrect Perl for(my $i = $len; $i > 0; --$i){ # correct Perl
YMMV as I haven't tried it out with these changes implemented.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: porting C code to Perl
by Discipulus (Canon) on Oct 23, 2017 at 19:55 UTC | |
by haukex (Archbishop) on Oct 23, 2017 at 20:08 UTC | |
by soonix (Canon) on Oct 23, 2017 at 20:31 UTC |
In Section
Seekers of Perl Wisdom