I had a cursory look at the Roguelike::UI module. A lot of places in the code you are
pushing a scalar onto an array inside a
foreach statement modifier when you could simply
push the list directly onto the array. In the following examples the lines with the line numbers are from your module and the lines following them are without the
foreach statement modifier:
159 push @rows, $_ foreach ($start .. $y);
push @rows, $start .. $y;
165 push @rows, $_ foreach ($y + 1 .. $end);
push @rows, $y + 1 .. $end;
193 push @cols, $_ foreach ($start2 .. $x);
push @cols, $start2 .. $x;
199 push @cols, $_ foreach ($x + 1 .. $end2);
push @cols, $x + 1 .. $end2;
257 push @msgs, $Game->{Messages}[-5 + $_] foreach 0 .. 4;
push @msgs, @{ $Game->{Messages} }[ -5 .. -1 ];
288 shift @{ $Game->{MsgLog} } foreach 1 .. $times;
splice @{ $Game->{MsgLog} }, 0, $times;
356 push @draw, $lines[$_] foreach $y1 .. $y2;
push @draw, @lines[ $y1 .. $y2 ];
The block:
265 if (scalar @lines > 5) {
266 @sayme = map { $lines[-$_] } (1 .. 5);
267 @sayme = reverse @sayme;
268 } else {
Could be simpified with an array slice to:
if (@lines > 5) {
@sayme = @lines[ -5 .. -1 ];
} else {
In a lot of places you use an ASCII ESC character which shows up in my editor as
"^[". Perl provides an escape sequence for the ASCII ESC character:
"\e" which is more readable.