in reply to Recipe of day - hashes q.
Go read perlop.pod. ?: binds tighter than = so the trailing = $k is outside the ?: construct.
is(exists $distinct{$v}) ? $overflow{$k} = $v : $distinct{$v} = $k;
which is like( (exists $distinct{$v}) ? $overflow{$k} = $v : $distinct{$v} ) = $k;
(exists $distinct{$v}) ? $overflow{$k} = $v = $k : $distinct{$v} = $k
The correct way to resolve the precedence problem is:
(: - tye (but my friends call me "Tye")if( $distinct{$v} ) { $overflow{$k}= $v } else { $distinct{$v}= $k }
|
|---|