in reply to Using 'sort' to emulate SQL's 'select'...
@fookeys = grep $HoH{$_}{foo} eq 'bar2', keys %HoH; print "@fookeys\n"; # Only `2' is there.
By the way, your usage of sort() is wrong. The comparison function used by sort() must involve both $a and $b, else sort() cannot do its job properly.
Also, you should realize that sort() will return a copy of _all_ the elements you ask it to sort; that's why you want grep().
|
|---|