Just too funny
By joe
- 2 minutes read - 301 wordsI do quite a bit of Perl programming work in support of our products. Perl is sometimes (mistakenly IMO) called a scripting language; it may have been designed to handle that in the past, but it has evolved over the decades into something far more powerful. But it also has this … well … implicit sense of humor about it. Maybe this is what pisses off people advocating other programming languages. I dunno.
Well, I was reading chromatic’s blog on use.perl.org, and ran across this snippet.
perl -e 'die screaming'
Ok. A quick explanation is needed. When you run “perl -e ‘a_one_liner’, perl will execute the a_one_liner for you. So
perl -e 'print 1+1'
will return 2. But it will do it without a newline, so you get something like this.
landman@balto:~$ perl -e 'print 1+1'
2landman@balto:~$
where landman@balto:~ $ is my command prompt on my laptop (running Ubuntu 7.04).
The ‘die’ command prints the string to its right to the terminal, and then exits. I usually use things that look like this
die "FATAL ERROR: something terrible just happened\n";
and the program does in fact do this.
So what, precisely, does
perl -e 'die screaming'
do? Only one way to find out …
landman@balto:~$ perl -e 'die screaming'
screaming at -e line 1.
or if you wrap it up into a program
landman@balto:~$ cat neat.pl
#!/usr/bin/perl
die screaming;
landman@balto:~$ ./neat.pl
screaming at ./neat.pl line 3.
landman@balto:~$
This is too funny. You have to remember, Perl has this huge repository of code called CPAN. Most of the code there is very helpful, allowing you to reuse rather than re-invent. Some of the code placed there continues on in this vein … Acme::Bleach Acme::EyeDrops which is touted as visual programming. Really. Go read the manual. Those programs are in fact executable. Scary.