my $num = 100; print "First digit of $num is " . int($num / (10 ** int(log(abs($num))/log(10)))) . "\n";