I was looking on how I could sort a file based on the length of each sentence and I came across this snippet from this answer
perl -ne 'push @a, $_ } { print sort { length $a <=> length $b } @a' input
^ ^
I tested it and it works but I don't have a clue how this works! As far as I can see the syntax is wrong. It has an open right bracket and a non closed right bracket which I have marked.
I am really having trouble figuring out how to run perl commands like this in bash
Could some one please explain this snippet?