I answered this in the CB when you asked there. Here it is again since you asked again.
You're assigning a list of keys to a hash when it takes a list of key-value pairs.
You assume the order of the key-value pairs you assign to a hash matters, but it doesn't.
As for the waning, it says you shouldn't use split to assign to @_. That's particularly true here since you don't want to assign to @_. (See the docs.) You can use $s=~tr/d// to count the number of instances of "d". You could also use (()=$s=~/d/g).
my @sorted_keys = sort { $a=~tr/d// <=> $b=~tr/d// } keys(%hash);
In reply to Re: Sorting a hash in one line
by ikegami
in thread Sorting a hash in one line
by rachitmohta11
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |