in reply to Re: aligning text
in thread aligning text

This is the output:

Belgian Waffles 5.95 Berry-Berry Belgian Waffles 8.95 French Toast 4.50 Homestyle Breakfast 6.95 Strawberry Belgian Waffles 7.95

And this is the desired output:

Belgian Waffles 5.95 Berry-Berry Belgian Waffles 8.95 French Toast 4.50 Homestyle Breakfast 6.95 Strawberry Belgian Waffles 7.95

Replies are listed 'Best First'.
Re^3: aligning text
by hippo (Archbishop) on Feb 02, 2018 at 15:43 UTC

    Since I doubt anyone else will suggest it, here's a perlform-based solution:

    #!/usr/bin/env perl use strict; use warnings; my @har = ( 'Belgian Waffles', 'Berry-Berry Belgian Waffles', 'French Toast', 'Homestyle Breakfast', 'Strawberry Belgian Waffles', ); my @prices = qw/ 5.95 8.95 4.50 6.95 7.95 /; my ($name, $price); format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<< @#.## $name, $price . for my $i (0 ..$#har) { $name = $har[$i]; $price = $prices[$i]; write; }
Re^3: aligning text
by dasgar (Priest) on Feb 02, 2018 at 15:57 UTC

    For that kind of formatting, I've used Text::Table as suggested by hippo. I'm not going to claim that this is the "best" way of doing, but I'd probably resort to using Text::Table if needed to format data into columns.