sub id2path_boftx { my $id = shift or return q(); # my $chunk_length = length $id > 6 ? 3 : 2; my $chunk_length = $id < 1e6 ? 2 : 3; my $path_pat = '%0' . $chunk_length . 'd'; $path_pat = join('/', $path_pat, $path_pat, $path_pat); my $chunk_power = 10 ** $chunk_length; my $path = sprintf $path_pat, $id / ($chunk_power ** 2), ($id / $chunk_power) % $chunk_power, $id % $chunk_power; return $path; }