Schwartzian transform

Dermot paikkos at gmail.com
Wed Aug 13 12:02:46 BST 2014


>
>
>     # Warning: map in void context used for side-effect of setting
> {position}...
>     # (I feel so dirty! ;-)
>     my $count = 1;
>     map  { $_->[1]{position} = $count++ }
>     sort { $a->[0] <=> $b->[0] }
>     map  { [$_->{position}, $_] }
>         values %{$ref};
>
>
>
That is filthy....but i like it. There are times I need to keep the
structure as a hashref so I can find items by their key and there are times
when I want to pass the data around as an ordered array so this works well
for me too.
Dermot


More information about the london.pm mailing list