YS One Liners
There's almost nothing I like more about programming than one liners.
A one liner is a single line of code that does something useful and doesn't require any extra steps to compile or run.
You type one line, press enter, and get your result.
I first learned about one liners in Perl.
If we have a file.txt
with the following content:
one
two
three
four
five
Here's a Perl one liner that counts the number of lines in a file:
$ perl -E '@l = <>; say scalar(@l)' < file.txt
5