Text Formatting and Date Strings
Padding Alignment
Pad text and numbers into a stable report row.
padding-alignment
Width specifiers help columns line up in fixed text output.
Padding Alignment
padding_alignment.pl
Replay: real traced execution (multi-file project)
use strict;
use warnings;
my $code = "A7";
my $count = 5;
my $row = sprintf("%-6s|%03d", $code, $count);
print "code=$code\n";
print "count=$count\n";
print "row=$row\n";
use strict;
use warnings;
my $code = "B12";
my $count = 5;
my $row = sprintf("%-6s|%03d", $code, $count);
print "code=$code\n";
print "count=$count\n";
print "row=$row\n";
use strict;
use warnings;
my $code = "LONG";
my $count = 5;
my $row = sprintf("%-6s|%03d", $code, $count);
print "code=$code\n";
print "count=$count\n";
print "row=$row\n";
$code ← A7, $count ← 5, $row ← A7 |005
4my $code→ A7 = "A7"; #@code="B12", "LONG"5my $count→ 5 = 5;6my $row→ A7 |005 = sprintf("%-6s|%03d", $codeA7, $count5);78print "code=$codeA7\n";9print "count=$count5\n";10print "row=$rowA7 |005\n";outputcode=A7 count=5 row=A7 |005
$code ← B12, $count ← 5, $row ← B12 |005
4my $code→ B12 = "B12";5my $count→ 5 = 5;6my $row→ B12 |005 = sprintf("%-6s|%03d", $codeB12, $count5);78print "code=$codeB12\n";9print "count=$count5\n";10print "row=$rowB12 |005\n";outputcode=B12 count=5 row=B12 |005
$code ← LONG, $count ← 5, $row ← LONG |005
4my $code→ LONG = "LONG";5my $count→ 5 = 5;6my $row→ LONG |005 = sprintf("%-6s|%03d", $codeLONG, $count5);78print "code=$codeLONG\n";9print "count=$count5\n";10print "row=$rowLONG |005\n";outputcode=LONG count=5 row=LONG |005