I am creating a cypher program. I want to transcript the key (given in $ARGV[1]) to a matrix of numbers.
But, I have some troubles figuring out how to print the array as a matrix without getting warnings/errors.
use strict;
use warnings;
use POSIX;
my @characters = split //, $ARGV[1];
@characters = map {ord($_)} 0 .. $#characters;
my $col_nb = ceil(sqrt($#characters));
for my $i (1 .. ($col_nb**2 - $#characters - 1)) { push @characters , 0; }
foreach my $i (0 .. $col_nb - 1) {
printf "%.0f\t" x $col_nb, @characters[$col_nb * $i .. $col_nb * ($i + 1)];
printf("\n");
}
I am triyng to get an output like this : (key = "abcd")
48 49
50 51
But, I get these errors on the output :
Redundant argument in printf at test.perl line 9.
48 49
Redundant argument in printf at test.perl line 9.
50 51