diff options
| author | wanderdoc <wanderdoc@googlemail.com> | 2019-12-24 20:22:26 +0100 |
|---|---|---|
| committer | wanderdoc <wanderdoc@googlemail.com> | 2019-12-24 20:22:26 +0100 |
| commit | b11c49f8caa6bf68a235283a7b7aaa5aa7db731f (patch) | |
| tree | 0a2ec016887a08cee5842fdbdbb71f67ad94fe9a | |
| parent | 2b602851a25b2cf3e34892d4d93daa42c88c08a3 (diff) | |
| download | perlweeklychallenge-club-b11c49f8caa6bf68a235283a7b7aaa5aa7db731f.tar.gz perlweeklychallenge-club-b11c49f8caa6bf68a235283a7b7aaa5aa7db731f.tar.bz2 perlweeklychallenge-club-b11c49f8caa6bf68a235283a7b7aaa5aa7db731f.zip | |
Modified ch-1.pl, first misunderstood the challenge.
| -rw-r--r-- | challenge-040/wanderdoc/perl5/ch-1.pl | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/challenge-040/wanderdoc/perl5/ch-1.pl b/challenge-040/wanderdoc/perl5/ch-1.pl index 4b4a1c6214..6609b7d062 100644 --- a/challenge-040/wanderdoc/perl5/ch-1.pl +++ b/challenge-040/wanderdoc/perl5/ch-1.pl @@ -20,8 +20,11 @@ Y 0 ^ O 1 & U 9 * =cut -use utf8; # Source file encoding. + +# Correction: there should be n arrays not just three. + +use utf8; # Source file encoding. binmode (STDOUT, ":encoding(cp850)"); # '£' in Windows cmd. my @arr_1 = qw(I L O V E Y O U); @@ -29,14 +32,33 @@ my @arr_2 = qw(2 4 0 3 2 0 1 9); my @arr_3 = qw(! ? £ $ % ^ & *); -for my $i ( 0 .. $#arr_1 ) -{ +print "@$_$/" for my_zip6(\@arr_1, \@arr_2, \@arr_3); - print join(' ', $arr_1[$i], $arr_2[$i], $arr_3[$i]), $/; -} -print "Now cheating with module: $/"; +print "Now cheating with module: $/"; use List::MoreUtils qw(zip6); -print "@$_$/"for zip6 @arr_1, @arr_2, @arr_3;
\ No newline at end of file +print "@$_$/" for zip6 @arr_1, @arr_2, @arr_3; + + +sub my_zip6 +{ + my @arefs = @_; + + my @result; + my $imax = $#{$arefs[0]}; + + for my $i ( 0 .. $imax ) + { + my @row; + for my $ar ( @arefs ) + { + push @row, $ar->[$i]; + + } + push @result, [@row]; + + } + return @result; +}
\ No newline at end of file |
