$bag->{$_}++ for @items; # instead of map {$bag->{$_}++} @items;