$ perl -v This is perl 5, version 28, subversion 1 (v5.28.1) built for x86_64-linux ... $ cat foo.txt one two three one five two ten one $ perl -anE '$h{$F[0]}++}{say qq|$_ appeared $h{$_}| for sort keys %h' foo.txt five appeared 1 one appeared 3 ten appeared 1 three appeared 1 two appeared 2 $ perl -anE '$h{$F[0]}++}{say qq|$_ appeared $h{$_}| for sort keys $h' foo.txt Experimental keys on scalar is now forbidden at -e line 1. Type of arg 1 to keys must be hash or array (not scalar dereference) at -e line 1, at EOF Execution of -e aborted due to compilation errors.