my %hash = ( foo => 1, bar => 2, baz => 3 ); my @result; foreach ( keys %hash ) { $result[ @result ] = "$_:$hash{ $_ }"; } #### my %hash = ( 1 .. 100000 ); timethese( 500000, { 'obfu' => 'my @result; for my $key ( keys %hash ) { $result[ @result ] = "$key:$hash{ $key }"; }', 'push' => 'my @result; for my $key ( keys %hash ) { push @result, "$key:$hash{ $key }"; }', }); #Results: #Benchmark: timing 500000 iterations of obfu, push... # obfu: 5 wallclock secs ( 2.93 usr + 0.01 sys = 2.94 CPU) @ 169836.96/s (n=500000) # push: 3 wallclock secs ( 2.94 usr + 0.00 sys = 2.94 CPU) @ 170357.75/s (n=500000) #### sub new { my ($class, $orderID, $owner, $limit) = @_; foreach (qw'orderID') { (croak __PACKAGE__ . "->new() needs a ${_}.") unless (eval("\$$_")) } # rest of constuctor ... }