Everything2
Near Matches
Ignore Exact
Full Text
Everything2

one liner

created by hornsby

(idea) by LordOmar (1.8 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.8 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.8 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
After stirring Everything, these nodes rose to the top:
Diaspora
Salvation for modern Dads
cavitation torpedo
It's a jailbreak; we're free.
The Robot
A Table Alphabeticall
nód as gaeilge
American Beauty
How Pac-Man and Ms. Pac-Man have sex
How to carve a dodecahedron out of a cube
December 6, 2006
Garrison Keillor
Getting an STI test
New Writeups
Cuckowski
Slavonic Princess(poetry)
Heitah
Posthumous Oscar(thing)
ignis_glaciesque
University of South Florida(place)
ignis_glaciesque
Flogstaskriket(idea)
liveforever
Caesar's last breath(idea)
dagnyswaggart
she wants to believe(personal)
antigravpussy
he doesn't know, but her eyes widen too far(thing)
dagnyswaggart
Wild tides guard her secrets(poetry)
Lord Brawl
Caesar's last breath(poetry)
locke baron
Forgotten things in space(fiction)
sitaraika
Colours(idea)
etouffee
Wild tides guard her secrets(poetry)
Lord Brawl
Dr. Horrible's Sing-Along Blog(review)
a8ksh4
regret(idea)
Heisenberg
Editor Log: July 2008(log)
This affordable entertainment brought to you by The Everything Development Company