I am experiencing issues completing a simple task. I have the following hash of hashes:
%hash = (
personA => {
2017 => 1,
2018 => 2,
},
personB => {
2015 => 4,
2013 => 28,
2014 => 1, .
},
personC => {
2013 => 3,
2011 => 2,
2012 => 45,
},
);
I am trying to print out the earliest year for each person, e.g. something like:
personA 2017
personB 2013
personC 2011
It seems that List::Util is the best tool for this, but I cannot find an example to adapt for my data. I am having trouble because the solutions I have found are trying to sort/print the first level of the hash (i.e., personA, etc.), as opposed to the years.
use strict;
use warnings;
my %hash;
my $hash;
%hash = (
personA => {
2017 => 1,
2018 => 2,
},
personB => {
2015 => 4,
2013 => 28,
2014 => 1,
},
personC => {
2013 => 3,
2011 => 2,
2012 => 45,
},
);
use List::Util qw(min);
my $min = min keys %hash;
$hash = {$min => $hash->{$min}};