#!/usr/local/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Indent = 1; my @AoA = ( [qw/10 27 17 20/], [qw/10 24 22 25/], [qw/11 25 24 25/], [qw/11 26 19 20/], ); my %HoH; foreach my $aref (@AoA) { my ($key1, $key2) = splice @$aref => 0, 2; @$aref = $aref->[0] .. $aref->[1]; # this creates the range $HoH{$key1}{$key2} = $aref; } print Dumper \%HoH;