aboutsummaryrefslogtreecommitdiff
path: root/challenge-040/andrezgz/perl5/ch-1.pl
blob: f05f91443fec2046a1b7c503f6b05f28a63f90cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl

# https://perlweeklychallenge.org/blog/perl-weekly-challenge-040/
# Task #1
# Show multiple arrays content
# You are given two or more arrays. Write a script to display values of each list at a given index.
#
# For example:
#
# Array 1: [ I L O V E Y O U ]
# Array 2: [ 2 4 0 3 2 0 1 9 ]
# Array 3: [ ! ? � $ % ^ & * ]
# We expect the following output:
#
# I 2 !
# L 4 ?
# O 0 �
# V 3 $
# E 2 %
# Y 0 ^
# O 1 &
# U 9 *

use strict;
use warnings;

use v5.20;
use feature qw(postderef);
no warnings qw(experimental::postderef);

my @arrays = (
    [qw/ I L O V E Y O U /],
    [qw/ 2 4 0 3 2 0 1 9 /],
    [qw/ ! ? � $ % ^ & * /]
);

my $max=0;
for (@arrays) {
    $max = $_->@* if ($_->@* > $max);
}

for my $i (0.. $max - 1) {
    print $_->[$i].' ' for @arrays;
    print $/;
}