my $start_run = time(); use strict; use Benchmark; use warnings; my @array = (1..1000000000); foreach (@array) { if ($_==reverse(substr($_, 0, 1) * substr($_, 1))) { print $_."\n" ;} if ($_==reverse(substr($_, 0, 2) * substr($_, 2))) { print $_."\n" ;} if ($_==reverse(substr($_, 0, 3) * substr($_, 3))) { print $_."\n" ;} if ($_==reverse(substr($_, 0, 4) * substr($_, 4))) { print $_."\n" ;} if ($_==reverse(substr($_, 0, 5) * substr($_, 5))) { print $_."\n" ;} if ($_==reverse(substr($_, 0, 6) * substr($_, 6))) { print $_."\n" ;} if ($_==reverse(substr($_, 0, 7) * substr($_, 7))) { print $_."\n" ;} } my $end_run = time(); my $run_time = $end_run - $start_run; print "Time taken: ".$run_time." sec\n";