tag:blogger.com,1999:blog-240639029338918802.post964482279834228762..comments2015-03-23T18:10:46.741-05:00Comments on Perl Squirrel: Perl one-liners: File Extension FrequencyUnknownnoreply@blogger.comBlogger1125tag:blogger.com,1999:blog-240639029338918802.post-17425960456266582352013-01-04T10:56:48.070-06:002013-01-04T10:56:48.070-06:00Perl makes it easier to write this one-liner using...Perl makes it easier to write this one-liner using some of its command line options.<br /><br />perl -lne '$f{$_}++; END {printf("%-40s %12i\n",$_,$f{$_}) foreach sort keys %f}'<br /><br />-n provides you the while loop that reads the input. You need to supply only the body of the loop. The code to be run after the while loop is wrapped in the END block.<br /><br />-l turns on auto-chomping of the the input lines.<br /><br />To make it even shorter, you can use `for' instead of `foreach'. There is no difference between the two.prahttps://www.blogger.com/profile/03343616686586177696noreply@blogger.com