#! perl -slw use strict; use Devel::Size qw[size total_size]; my @cases = ( { class=>'classA', fv=>{ featureA=>1, featureB=>1, featureC=>1, featureD=>1 } }, { class=>'classB', fv=>{ featureA=>1, featureB=>1, featureE=>1, featureF=>1 } }, { class=>'classC', fv=>{ featureB=>1, featureC=>1, featureD=>1, featureE=>1 } }, { class=>'classD', fv=>{ featureC=>1, featureD=>1, featureE=>1, featureF=>1 } }, { class=>'classE', fv=>{ featureA=>1, featureD=>1, featureE=>1, featureF=>1 } }, { class=>'classF', fv=>{ featureD=>1, featureE=>1, featureF=>1, featureG=>1 } }, { class=>'classG', fv=>{ featureA=>1, featureC=>1, featureD=>1, featureG=>1 } }, { class=>'classH', fv=>{ featureA=>1, featureB=>1, featureD=>1, featureG=>1 } }, { class=>'classI', fv=>{ featureA=>1, featureC=>1, featureE=>1, featureF=>1 } }, { class=>'classJ', fv=>{ featureB=>1, featureD=>1, featureF=>1, featureG=>1 } }, ); use constant FEATURE_A=>0; use constant FEATURE_B=>1; use constant FEATURE_C=>2; use constant FEATURE_D=>3; use constant FEATURE_E=>4; use constant FEATURE_F=>5; use constant FEATURE_G=>6; my %cases = ( classA=>[ 1, 1, 1, 1, 0, 0, 0 ], classB=>[ 1, 1, 0, 0, 1, 1, 0 ], classC=>[ 0, 1, 1, 1, 1, 0, 0 ], classD=>[ 0, 0, 1, 1, 1, 1, 0 ], classE=>[ 1, 0, 0, 1, 1, 1, 0 ], classF=>[ 0, 0, 0, 1, 1, 1, 1 ], classG=>[ 1, 0, 1, 1, 0, 0, 1 ], classH=>[ 1, 1, 0, 1, 0, 0, 0 ], classI=>[ 1, 0, 1, 0, 1, 1, 0 ], classJ=>[ 0, 1, 0, 1, 0, 1, 1 ], ); print 'Array of hash of hash : ', total_size( \@cases ); print 'Hash of array : ', total_size( \%cases ); __END__ C:\test>test2 Array of hash of hash : 4088 Hash of array : 2534