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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.