Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Favourite One-liners?

by chas (Priest)
on Jun 27, 2005 at 22:28 UTC ( #470405=note: print w/replies, xml ) Need Help??

in reply to Favourite One-liners?

I think the first I learned was: perl -pe 0 "filename". Rather trivial, but it took a bit of thought to understand what the "0" was.
For illustrating the power of Perl, I like perl-MLWP::Simple -e "print get(shift)"

(Those are for Win; Single quotes may be better on *nix.)

Replies are listed 'Best First'.
Re^2: Favourite One-liners?
by epoptai (Curate) on Jun 28, 2005 at 19:47 UTC
    FYI LWP::Simple can get and print with one command:
    perl -MLWP::Simple -e "getprint ''"
    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"

      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 :)

Re^2: Favourite One-liners?
by ikegami (Pope) on Jun 28, 2005 at 18:40 UTC
    If you're using ActiveState, just do
      Er, what does using activestate have to do with the ability to execute the GET program (which comes with LWP) ?
        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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://470405]
[ambrus]: As for TeX, I'm not trying to discourage anyone from writing carefully beautifully typeset documents, in maths or outside. But most people aren't willing to do that, and will spend only little time about the formatting,
[ambrus]: and try to leave everything else to automated systems without checking how what they write came out format-wise, and for those people, discounting the part about journals with a specific format above,
[ambrus]: just blindly recommending to use LaTeX is a bad idea now.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-09-26 11:20 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.