mseabrook has asked for the wisdom of the Perl Monks concerning the following question:
Wherein I call on the perl monks to aid me in my misguided quest to reduce some perfectly understandable, and fairly minimal code into a one-liner.
Given the following code, which uses a hash find the unique things in a list of such,
my %this_to_that = map {$_->this => $_} @things; return values %this_to_that;
How does one obviate the need for the temporary (named) hash? I naively expect something like the following to work, but does it does not.
return values %{map {...} @things} Type of arg 1 to values must be hash (not anonymous hash ({})) at...
Is it possible to do this with an anonymous hash?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get values from anonymous hash?
by blue_cowdawg (Monsignor) on Aug 17, 2011 at 19:40 UTC | |
|
Re: Get values from anonymous hash?
by CountZero (Bishop) on Aug 17, 2011 at 19:46 UTC | |
by mseabrook (Beadle) on Aug 17, 2011 at 20:02 UTC | |
|
Re: Get values from anonymous hash?
by parv (Parson) on Aug 17, 2011 at 19:25 UTC | |
|
Re: Get values from anonymous hash?
by blue_cowdawg (Monsignor) on Aug 17, 2011 at 19:45 UTC | |
by mseabrook (Beadle) on Aug 17, 2011 at 20:00 UTC |