diff --git a/lpst.pl b/lpst.pl index 07f3e32..14292e6 100644 --- a/lpst.pl +++ b/lpst.pl @@ -4,6 +4,7 @@ use warnings; use strict; +my $PAD_AXIS = " "; my $PAD_EVEN = " "; my $PAD_ODD = " "; @@ -11,6 +12,8 @@ my $HEX_1 = '-/--\-'; my $HEX_2 = '| __ |'; my $HEX_3 = '| |'; +my $SUB_CHR = "_"; + my $PREF_1 = substr($HEX_1, -2, 2); my $PREF_2 = ' '; my $PREF_3 = ' '; @@ -51,6 +54,10 @@ my %AXIS = ( "J" => 10, "K" => 11 ); +my %AXIS_RV = map { + $AXIS{$_} => $_ +} keys(%AXIS); + # # /--\ +1 @@ -270,12 +277,51 @@ sub disp_row($){ return $row; } +sub disp_y_axis(){ + my $s0; + + $s0 = $PAD_AXIS; + $s0 .= join( + $PAD_AXIS, map{ + $AXIS_RV{$_} + }(1..11)); + $s0 .= "\n"; + + return $s0 +} + +sub disp_trailing_row(){ + my $s0; + my $s1; + + $s0 = $PAD_EVEN.$PREF_1; + + # Clear some chars from + # our hex patterns + $s1 = $HEX_1; + substr($s1, 2,2) = " "; + + # Append hex pattern to + # trailing row + for my $i (1..11){ + $s0 .= $s1; + } + # Clear one last pair of + # chrs + substr($s0, -2,2) = " "; + $s0 .= "\n"; + + return $s0; +} + sub disp_board(){ my $b; for my $i (map {11-$_+1} (1..11)) { $b .= disp_row($i); } + $b .= disp_trailing_row(); + $b .= disp_y_axis(); $b =~ s/$TRAIL_1$TRAIL_3\n/\n/m; for my $i (1..11-1){ @@ -295,7 +341,9 @@ sub cell_index($){ my $l0; $l0 = $_; (map {$l0.$_} ("1".."11")) -} ("A".."K"); +} map{ + $AXIS_RV{$_} +}(1...11); disp_board();