Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror

Comment 7 languages in one program (Score 2, Funny) 174

http://blog.sykosopp.com/2006/02/26/one-file-to-ru le-them-all/

Embed all your languages, this file can be interpreted or compiled in 7 different coding languages:

$ php poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
#I'm a PHP script
$ python poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
I'm a Python program.
$ perl poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
I'm a Perl program.
$ tclsh poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
I'm a tcl script.
$ sh poly.sh.pl.php.tcl.cpp.bf.py.c.lhs.txt
I'm a sh script.

Rename file to compile in C/C++:

$ gcc p.c -o c;./c
I'm a C program (C89 with // comments, trigraphs disabled).
$ g++ p.c -o cp;./cp
I'm a C++ program, trigraphs disabled.

Slashdot Top Deals

"The voters have spoken, the bastards..." -- unknown

Working...