1 2 3 4 5
$m = 1000; for $x ( 2..$m ) { $c{$x**$_}++ for 2..log($m)/log$x } print join ' ', grep { $c{$_} > 1 } keys %c
1
729 16 512 625 64 81 256