#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11136164 use warnings; my @data = map [ /\S+(?: \(\S+)?/g ], <DATA>; my @wide; for my $line ( @data ) { $wide[$_] |= '' . $line->[$_] for 0 .. $#$line; } $_ = sprintf "%%-%ds", length for @wide; my $format = join(' ', @wide) . "\n"; #printf $format, @$_ for @data; # previous code my $table = join '', map { sprintf $format, @$_ } @data; # new combine + code print $table;
In reply to Re^3: Align columns in a table
by tybalt89
in thread Align columns in a table
by ovedpo15
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |