http://qs321.pair.com?node_id=1201910


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.