aboutsummaryrefslogtreecommitdiff
path: root/challenge-008/maxim-nechaev/perl5/ch-2.pl
blob: 5dfc16ddff5ee2b67795ff86e69cdd806c6b749f (plain)
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/perl -w
use strict;
use feature 'say';
use List::Util qw/reduce/;

sub center {
    my $len = length reduce { length $a > length $b ? $a : $b } @_;
    return map { $^A=''; formline '@'.'|' x $len, $_; $^A } @_;
}

map { say } center('This', 'is', 'a test of the', 'center function');