Re: Getting keys of mapped hash?

2001-01-03 Thread Shevek
On Tue, 2 Jan 2001, Peter Corlett wrote: On Sat, Dec 30, 2000 at 06:35:18PM +, Tony Bowden wrote: i.e. something akin to: my @sort = sort keys map { $_ = 1 } @list; I'm thinking that this might work: my @sort=sort keys %{ +{ map { $_ = undef } @list } }; Maybe I'm missing something

Re: Getting keys of mapped hash?

2001-01-03 Thread alex
On Wed, 3 Jan 2001, Shevek wrote: my @sort=sort keys %{ +{ map { $_ = undef } @list } }; Maybe I'm missing something here, but how is this different to my @sort = sort @list; values in @sort are unique?

Getting keys of mapped hash?

2001-01-02 Thread Tony Bowden
OK, my brain has fried. How can I do this: my @list = qw/foo bar foo baz/; my %hash = map { $_ = 1 } @men; my @sort = sort keys %hash; print "We have @sort\n"; # foo bar baz without the %hash? i.e. something akin to: my @sort = sort keys map { $_ = 1 } @list; I've tried so many

Re: Getting keys of mapped hash?

2001-01-02 Thread Peter Corlett
On Sat, Dec 30, 2000 at 06:35:18PM +, Tony Bowden wrote: i.e. something akin to: my @sort = sort keys map { $_ = 1 } @list; I'm thinking that this might work: my @sort=sort keys %{ +{ map { $_ = undef } @list } };

RE: Getting keys of mapped hash?

2001-01-02 Thread Jonathan Peterson
my @sort=sort keys %{ +{ map { $_ = undef } @list } }; ^^ ?? What does +{} do???

Re: Getting keys of mapped hash?

2001-01-02 Thread Richard Clamp
On Tue, Jan 02, 2001 at 03:21:15PM -, Jonathan Peterson wrote: my @sort=sort keys %{ +{ map { $_ = undef } @list } }; ^^ ?? What does +{} do??? It says 'Yes damnit, I want an anonymous hash here, not one of those pesky block thingies' -- Richard Clamp

RE: Getting keys of mapped hash?

2001-01-02 Thread Jonathan Peterson
What does +{} do??? It says 'Yes damnit, I want an anonymous hash here, not one of those pesky block thingies' Ah. Not closely related to the concept of addition then. Couldn't they have used !%{} or +%{} or something? Also, what _IS_ +{ in this case? It's not an operator, so is +{ simply

Re: Getting keys of mapped hash?

2001-01-02 Thread Peter Corlett
On Tue, Jan 02, 2001 at 03:36:17PM -, Jonathan Peterson wrote: [ on +{ ... } ] Is this explained in the latested Camel, because it doesn't show up in my pocket refernce at all It's almost a compile-time pragma, and I'm fairly sure it's in the camel. Anyway, "perlop" has this to say: