Fences are a side effect of 'reduce'...
#!/usr/bin/perl
use strict; # https://perlmonks.org/?node_id=1216162
use warnings;
use List::AllUtils qw( reduce pairwise );
my @trip = ("Chicago", "Saint Looey", "Joplin", "OKC", "Amarillo", "
+Gallup",
"Flagstaff", "Winona", "Kingman", "Barstow", "San Bernandino", "LA"
+);
reduce { printf "%15s to %-15s\n", $a, $b; $b } @trip;
my @states = ("IL", "MO", "MO", "OK", "TX", "TX",
"AZ", "AZ", "AZ", "CA", "CA", "CA" );
my %info = pairwise { $a => { state => $b } } @trip, @states;
use Data::Dump 'dd'; dd \%info;
print "\n", $info{Joplin}{state}, "\n";
Outputs:
Chicago to Saint Looey
Saint Looey to Joplin
Joplin to OKC
OKC to Amarillo
Amarillo to Gallup
Gallup to Flagstaff
Flagstaff to Winona
Winona to Kingman
Kingman to Barstow
Barstow to San Bernandino
San Bernandino to LA
{
"Amarillo" => { state => "TX" },
"Barstow" => { state => "CA" },
"Chicago" => { state => "IL" },
"Flagstaff" => { state => "AZ" },
"Gallup" => { state => "TX" },
"Joplin" => { state => "MO" },
"Kingman" => { state => "AZ" },
"LA" => { state => "CA" },
"OKC" => { state => "OK" },
"Saint Looey" => { state => "MO" },
"San Bernandino" => { state => "CA" },
"Winona" => { state => "AZ" },
}
MO
Indexes? We don't need no stinking indexes!