App-GUI-GoLP

 view release on metacpan or  search on metacpan

bin/golp  view on Meta::CPAN

    my $y = 0;
    my $count = "";

    foreach my $char (split //, $rle_data) {
        if ($char =~ /\d/) {
            $count .= $char;  # Accumulate digit characters
        } elsif ($char eq 'b' || $char eq 'o') {
            $count = $count eq "" ? 1 : $count; # Default count is 1
            my $state = ($char eq 'o') ? 1 : 0; # 'o' is live (1), 'b' is dead (0)
            
            # Fill the grid with the decoded run
            for (1 .. $count) {
                $rows[$y][$x++] = $state;
            }
            $count = "";  # Reset count
        } elsif ($char eq '$') {
            $count = $count eq "" ? 1 : $count;
            for (1 .. $count) {
                $y++;
                $x = 0; # Move to the next row
            }



( run in 0.989 second using v1.01-cache-2.11-cpan-9383018d099 )