use feature 'state'; use Math::Fleximal; sub getnext { state $num = Math::Fleximal->new("A", [qw/A B C D F G H J K L M N P Q R S T V X Y Z/]); do { $num=$num->add("B") } until $num->to_str!~/A/; return $num->to_str; } print getnext."\n" for 1 .. 1000; __END__ B C D ... Y Z BB BC BD ... ZY ZZ BBB BBC ...