Everything2
Near Matches
Ignore Exact
Full Text
Everything2

one liner

created by hornsby

(idea) by LordOmar (1.6 y) (print)   ?   I like it! Sat Nov 13 1999 at 9:12:18

A witty retort or A line which by itself is funny. Commonly used in action films. Some great examples can be found in Independance Day and Die Hard, as well as Army of Darkness. A prequisite of being an action hero is to be able to come up with pithy one-liners.

(thing) by hornsby (4.6 y) (print)   ?   I like it! Sun Nov 14 1999 at 9:01:13

A programming solution accomplished in one line of code. Usually written in perl, one liners are often used to express the elegance of a programming language. Perl hackers often claim to be able to equate any C program to one line of perl; however, this may just be an example of hubris.

(thing) by lenz (2.6 y) (print)   ?   I like it! Thu Jan 29 2004 at 14:03:52

If you are an adept of the Perl programming language, you will often find yourself typing one-liners to solve common system administration tasks, the kind you'd solve with sed or grep. Perl offers in fact a special mode of invocation with the switch -e where it gets passed a whole program on the command line, like in this case:
perl -e "print grep /^h/i, glob('*.txt');"
That prints the names of all the text files in the current directory starting with the letter h (something like dir h*.txt, but this is just a silly example - you can use the raw power of regular expressions to code complex matching rules).

What most people don't know is that you can actually repeat the -e switch more than once, so that you can actually build programs of more than one line using the one-liner syntax like in this case:

perl -e "print grep /^h/i, glob('*.txt');" \
     -e "print 'Hello, world\n;"
This way you can be sure you'll never be out of space for your one-liners.

A different option that's often used for one-liners is the auto-loop option -n, that reads from STDIN or the passed filename and loops on each input row. This way you can build simple one liners like the following

perl -n -e "print lc;" x.txt
Where all of the lines of x.txt will be printed in lowercase to STDOUT.

But the true Swiss-Army Chainsaw nature of Perl only shows when you add the -M (module) switch, where you can import any module available to your Perl and use it. This program, for instance, downloads and prints the Everything2 home page using the LWP::Simple web access module:

perl -MLWP::Simple -e 'print get("http://www.everything2.com";)'
That's not bad for one line of code.

printable version
chaos

one-liner A sexist joke I'm allowed to tell, due to being a woman Hubris The post-encounter hair check
The Art Of Insulting - Chapter XI - Miscellaneous Insults Perl Shortest mathematical joke somatotropin
A Society of People Named Elihu the great practical joke feud Primality testing with Perl regexs 255.255.255.255
no spectators I Started a Joke Things that I've overheard Chocolate-Covered Musings
Joe E. Lewis Myron Cohen The funniest joke in the world Sheriff John Burnell
Why women wear makeup and perfume So this one-legged man walks into a bar A language is a dialect with an army and a navy grep
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Look at this mess the Death Borg made!
Irenaeus
Planet of the Apes
Euchre
Roast Potatoes
Koala
The United States is already at war with Iraq
Ram Dass
Send me the pillow, the one that you dream on
cuneiform
harmony
Until the End of the World
two-fold cost of sex
Edward IV
New Writeups
russdog
Salt Lake City, Utah(person)
Scaevola
Risk in the Roman law of sale(idea)
semicolon
overheard at IHOP(event)
choirotey
Violent pickup lines(idea)
Ouzo
Blue Ovaries, Grrrrrrwl(log)
uncljoedoc
explanation(person)
Noung
One no longer loves one's insight when one communicates it(idea)
AspieDad
Pornology(essay)
nailbiter
Nicole duFresne(person)
Simulacron3
stigmergy(idea)
nakusavi
Yesterday I learned how to kiss(idea)
aneurin
UK Local Elections 2008(event)
Phyrkrakr
Kansas City Royals(thing)
niruena
Amalric of Bena(person)
niruena
Third Crusade(event)
This page courtesy of The Everything Development Company