in reply to Re: How would I write this using map?
in thread How would I write this using map?

The code most likely works. Without knowing the object internals you really can not say what things the object contains and in what data structure. A hash is the most natural way to store data with objects so I would assume that things returns a hash.
--
seek $her, $from, $everywhere if exists $true{love};

Replies are listed 'Best First'.
Re^3: How would I write this using map?
by monarch (Priest) on Jan 13, 2009 at 23:56 UTC
    I can't see how this would work. I tried to create some mock code:
    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() ) );
    but kept getting this error:
    Type of arg 1 to keys must be hash (not subroutine entry) at /tmp/deleteme.pl line 25, near ") ) "
Re^3: How would I write this using map?
by trwww (Priest) on Jan 14, 2009 at 00:17 UTC

    You cant return a hash from a function. Only lists and scalars.

      Got modded down for being right :-)