in reply to log() and int() problem
log returns a floating-point number, so the results are prone to floating-point inaccuracies:
$ perl -wE 'printf "%.20f\n", log(125)/log(5)' 3.00000000000000044409
A safer test is something like this here, which only uses integers:
use strict; use warnings; use 5.010; sub is_power_of { my ($num, $base) = @_; while ($num > 1) { return 0 if $num % $base != 0; $num /= $base; } return 1; } say is_power_of(125, 5);
In Section
Seekers of Perl Wisdom