Acme-Text-Rhombus

 view release on metacpan or  search on metacpan

lib/Acme/Text/Rhombus.pm  view on Meta::CPAN

    my ($mode, $lines, $char, $case, $fillup, $forward) = @_;

    my ($is_letter, $is_digit, $is_random) = ($mode eq 'letter', $mode eq 'digit', $mode eq 'random');

    my %alter = (
        lower => sub { lc $_[0] },
        upper => sub { uc $_[0] },
    );
    $char = $alter{$case}->($char) if $is_letter;

    my @chars = map chr, (48..57, 65..90, 97..122);
    $char = $chars[int(rand(@chars))] unless defined $char;

    $lines++ if $lines % 2 == 0;

    my ($line, $repeat, $rhombus);

    for ($line = $repeat = 1; $line <= $lines; $line++) {
        my $spaces = ($lines - $repeat) / 2;

        $rhombus .= $fillup x $spaces;



( run in 0.498 second using v1.01-cache-2.11-cpan-65fba6d93b7 )