I want to output a table containing four variables, an example of the desired format is:
A confusion matrix
H | P |
-----------------------
$var1 | $var2 | H
$var3 | $var4 | P
The problem I am having is that depending on the number of digits in the variables, the format changes and the various lines are offset. I know this is a complete noobie question, but I have never had to pay too much attention to the format of output before, its just one of those little things I want to get right this time. Any help at all would be great, thanks.
print() operator – print operator in Perl is used to print the values of the expressions in a List passed to it as an argument. Print operator prints whatever is passed to it as an argument whether it be a string, a number, a variable or anything. Double-quotes(“”) is used as a delimiter to this operator.
#!/usr/bin/perl use strict; use Template; my $template=Template->new({PRE_CHOMP => 1}); my @rows; push @rows,["a","b","c","d","e"]; push @rows,["a","b","c","d","e"]; push @rows,["a","b","C","d","e"]; push @rows,["a","b","c","d","e"]; $template->process("table.
Defining a Format Syntax to define a Perl Format: format FormatName = fieldline value_1, value_2, value_3 fieldline value_1, value_2, value_3 . – Name of the format is denoted by the FormatName. – Fieldline is a particular way used to format the data.
Text::Table, Text::SimpleTable::AutoWidth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With