perl -MLWP::Simple -e "getprint 'http://www.perlmonks.org'"
Here's a webserver, from the IO::All docs:
perl -MIO::All -e 'io(":8080")->fork->accept->(sub { $_[0] < io(-x $1
+? "./$1 |" : $1) if /^GET \/(.*) / })'
--
perl -MO=Deparse -e"u j t S n a t o e h r , e p l r a h k c r e"
| [reply] [d/l] [select] |
One line web server? Way cool.
A couple of years ago I went back to uni for a network communication class I failed once. After completing the lab assignment of writing a "time-of-day" server in C, I showed the lab instructor the equivalent perl code (one-liner). He thought it was pretty cool (I know, the lab goal is not the end result, but the methods you use to get there, but still..)
Had I known about IO::All and one-line web servers at the time, I might have gotten extra points on the lab assignment :)
| [reply] |
If you're using ActiveState, just do
GET http://www.perlmonks.org/ | [reply] [d/l] |
Er, what does using activestate have to do with the ability to execute the GET program (which comes with LWP) ?
| [reply] |
Simple. It guarantees that he can use GET. I didn't say he couldn't if he didn't have ActiveState. He possibly can. He possibly can't. It depends on whether he installed GET when he installed LWP.
| [reply] |