Hi G0G0
Why do you need the @array? You could improve the required memory by changing
my @array = (1..1000000000);
foreach (@array) {
to
foreach (1..1000000000) {
(The first solution gives an "out of memory" on my system, the later runs in 50 seconds with an empty loop).
Inside the loop, you can probably save some time by reversing only once, and storing the intermediate result in a temporary variable.
And based on the size of the current number, you could determine which of the substr-lines is relevant and skip the others...
HTH, Rata