Math::String::Charset 1.27 review

Math::String::Charset is a simple charset for Math::String objects. SYNOPSIS use Math::String::Charset; \$a = new Mat

Math::String::Charset is a simple charset for Math::String objects.

SYNOPSIS

use Math::String::Charset;

\$a = new Math::String::Charset; # default a-z
\$b = new Math::String::Charset ['a'..'z']; # same
\$c = new Math::String::Charset
{ start => ['a'..'z'], sep => ' ' }; # with ' ' between chars

print \$b->length(); # a-z => 26

# construct a charset from bigram table, and an initial set (containing
# valid start-characters)
# Note: After an 'a', either an 'b', 'c' or 'a' can follow, in this order
# After an 'd' only an 'a' can follow
\$bi = new Math::String::Charset ( {
start => 'a'..'d',
bi => {
'a' => [ 'b', 'c', 'a' ],
'b' => [ 'c', 'b' ],
'c' => [ 'a', 'c' ],
'd' => [ 'a', ],
'q' => [ ], # 'q' will be automatically in end
}
end => [ 'a', 'b', ],
} );
print \$bi->length(); # 'a','b' => 2 (cross of end and start)
print scalar \$bi->class(2); # count of combinations with 2 letters
# will be 3+2+2+1 => 8

\$d = new Math::String::Charset ( { start => ['a'..'z'],
minlen => 2, maxlen => 4, } );

print \$d->first(0),"n"; # undef, too short
print \$d->first(1),"n"; # undef, to short
print \$d->first(2),"n"; # 'aa'

\$d = new Math::String::Charset ( { start => ['a'..'z'] } );

print \$d->first(0),"n"; # ''
print \$d->first(1),"n"; # 'a'
print \$d->last(1),"n"; # 'z'
print \$d->first(2),"n"; # 'aa'

This module lets you create an charset object, which is used to contruct Math::String objects. This object knows how to handle simple charsets as well as complex onex consisting of bi-grams (later tri and more).

In case of more complex charsets, a reference to a Math::String::Charset::Nested or Math::String::Charset::grouped will be returned.

The default charset is the set containing "abcdefghijklmnopqrstuvwxyz" (thus producing always lower case output).

Requirements:
perl5.005
Exporter
Math::BigInt

Math::String::Charset 1.27 keywords