in reply to Re^4: Count of patterns in a file without knowing pattern in advance
in thread Count of patterns in a file without knowing pattern in advance

perl -anE "$h{$F[0]}++}{say qq|$_ appeared $h{$_}| for sort keys %h" *YOUR-FILE*
Unfortunately, this experimental feature no longer exists in perl version 5.24.1 and forward...produces the following error message: "Experimental keys on scalar is now forbidden at -e line 1."

Are you sure? I don't see that feature being used in this script, did you perhaps make a typo when copying it? (Update: Note the $h vs. %h in the final example below.)

$ perl -v This is perl 5, version 28, subversion 1 (v5.28.1) built for x86_64-li +nux ... $ 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) a +t -e line 1, at EOF Execution of -e aborted due to compilation errors.