use strict; { package MyObj; sub new { my %obj; bless( \%obj, $_[0] ); return( \%obj ); } sub items { my @things = ( 'key1' => 'v1', key2' => 'v2', ); return( @things ); } } my $myobj = MyObj->new(); print( "$_\n" ) foreach ( sort keys( $myobj->items() ) ); #### Type of arg 1 to keys must be hash (not subroutine entry) at /tmp/deleteme.pl line 25, near ") ) "