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.7 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
Nodes to live by:
Rosette-forming Crassulaceae
feudalism
Chastity Mangle
Baby Wants Gravy
Yankee Hotel Foxtrot
giraffe
Jesus and faggots
Brian Eno Random Node Conspiracy
Scenes from a Memory
Japanese numbers and counting
Also Sprach Zarathustra
Ed Gein
William Gladstone
New Writeups
aneurin
British Monomarks(idea)
FrankThomas
How and why do we (humans) have culture?(essay)
lee_cad
Isaac(person)
kalen
downvota(poetry)
Andrew Aguecheek
Wstfgl(thing)
ncc05
overheard at IHOP(event)
calgon
Bottomless(poetry)
lismaraxt
Ice Theory of The Origin of Life(idea)
allthetime
Apple Cinnamon Suicide(idea)
Lucy-S
shovelglove(idea)
Adaptive Child
Mexican secret sauce(recipe)
Adaptive Child
nacho libre(recipe)
TheLady
Iron Man(review)
Scaevola
Risk in the Roman law of sale(idea)
semicolon
overheard at IHOP(event)
This page courtesy of The Everything Development Company