#!/usr/bin/perl use strict; my (%hash, %large_data_structure_hash, @arr); # fill hash and array foreach ( qw/i1 i2 i3 i4 i5 i6 i7 i8 i9 i10/ ) { $hash{$_} = #data structure with lots of info; push @arr, $_; #array used for random key selection } #randomly select a few item from hash and get its data foreach(1 .. 4) { my $random_element = $arr[ rand @arr ]; #randomly select key my %large_data_structure_hash = %{ $hash{$random_element} }; #do whatever I want with %large_data_structure_hash } exit;