in reply to Re^4: underline variable width column headings
in thread underline variable width column headings

The columns aren't lining up because the character string returned by colored ($x, "underline") is longer than $x, typically by eight characters. That means that sprintf "%2s", colored(...) will never add an extra space.

The easiest way that I can think of to handle this is to put in the extra spaces as an explicit extra step, like this:

push @line, " " x ( 2 - length scalar @{ $trigraphs{$k} } ) . colored( scalar @{ $trigraphs{$k} }, 'underline' ) . colored( $k, 'underline' ) . colored( scalar keys %{ $flanks{$k} }, 'underline' ) . " " x ( 2 - length scalar keys %{ $flanks{$k} } );

Replies are listed 'Best First'.
Re^6: underline variable width column headings
by wlegrand (Initiate) on Dec 19, 2006 at 01:51 UTC
    Quester, Perfect! Thank you for your code. Thank you for your explanations. Thank you for showing me an excellent way to break across lines, ... but most of all ... Thank you for going the extra mile in helping a novice.