in reply to Arrays to Hash Issue
Output:use strict; use warnings; use 5.012; use List::MoreUtils qw/each_array/; my @first = qw/1 2 3 4 5 6/; my @second = qw/a b c d e f/; my $ea = each_array(@first, @second); while ( my ($f, $s) = $ea->() ) { say "First: $f -> second: $s" }
Or even shorter (but less flexible):First: 1 -> second: a First: 2 -> second: b First: 3 -> second: c First: 4 -> second: d First: 5 -> second: e First: 6 -> second: f
use strict; use 5.012; use List::MoreUtils qw/pairwise/; my @first = qw/1 2 3 4 5 6/; my @second = qw/a b c d e f/; pairwise { say "First: $a -> second: $b" } @first, @second;
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|