in reply to Recipe of day - hashes q.

Go read perlop.pod. ?: binds tighter than = so the trailing = $k is outside the ?: construct.

(exists $distinct{$v}) ? $overflow{$k} = $v : $distinct{$v} = $k;
is
( (exists $distinct{$v}) ? $overflow{$k} = $v : $distinct{$v} ) = $k;
which is like
(exists $distinct{$v}) ? $overflow{$k} = $v = $k : $distinct{$v} = $k

The correct way to resolve the precedence problem is:

if( $distinct{$v} ) { $overflow{$k}= $v } else { $distinct{$v}= $k }
(:

        - tye (but my friends call me "Tye")