in reply to How would I write this using map?
Hello,
I don't think your code works. In keys $obj->things, keys probably complains about not being given a hash.
Anyhoo, You don't need map here:
$things = [ sort keys %{$obj->things} ];A common reason you'd want map is if ->things returned a list of objects and you needed to call a method on all of them and collect the output:
# an array ref of all the things' names $names = [ map $_->name, $obj->things ];
hth,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How would I write this using map?
by puudeli (Pilgrim) on Jan 13, 2009 at 11:04 UTC | |
by monarch (Priest) on Jan 13, 2009 at 23:56 UTC | |
by trwww (Priest) on Jan 14, 2009 at 00:17 UTC | |
by trwww (Priest) on Jan 14, 2009 at 23:51 UTC |