in reply to Re^3: Perl slower than java
in thread Perl slower than java

I saw no real issues with your code.

Style-wise, @$chromosome1[$i] is needless use of an array slice, $$chromosome1[$i] and $chromosome1->[$i] are more appropriate. (The latter is usually considered more readable, but they are equivalent.)

Also, for my $i ( 0 .. ( $population_size - 1 ) ) { ...; $new_population[$i] = ...; } could be simplified to for ( 1 .. $population_size ) ) { ...; push @new_population, ...; }

Performance-wise, there's some array copying that could probably be avoid. Some can definitely be avoided by returning an array instead of a reference to an array. I don't know if it'll amount to much time.

Also, you're recompiling /\d/ and /\D/ repeatedly. Perhaps you should use qr/\d/ and qr/\D/ instead of '\d' and '\D'. This won't amount to much, I suspect.

There's surely tricks you can use to speed up your code, but that's not to say you did anything wrong.

Perl is typeless. That will make it slower in general. You might want to take a peak at PDL for this project.