my $ary_ref; my $hash_ref; my $ary_out; my $hash_out; timethese( 1_000, { array_way => sub { if (!$ary_ref) { $ary_ref = $dbh->selectall_arrayref($statement); $ary_out = show_all_except($ary_ref,[0]); }; print $ary_out; }, hash_way => sub { if (!$hash_ref) { $hash_ref = $dbh->selectall_hashref($statement, $key_field); $hash_out = show_these($hash_ref,[ 'field1','field2','field3' ]); }; print $hash_out; } } );