Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Fence vs. Posts

by tybalt89 (Monsignor)
on May 29, 2024 at 03:55 UTC ( [id://11159704]=note: print w/replies, xml ) Need Help??


in reply to Fence vs. Posts

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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11159704]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2026-04-15 15:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.