Strings In Depth15 / 18
Up next

Format with sprintf

use strict;
use warnings;
use feature 'say';

# %-8s left-justifies, %5.2f pads a float
my $line = sprintf("%-8s %5.2f", "pi", 3.14159);
say $line;
# %#x adds the 0x hex prefix
say sprintf("%#x", 255);
What you're solving

build a formatted string