in reply to Re: Just Another Thread Hacker
in thread Just Another Thread Hacker

While we're at it... golfed down from liz's 301 keystrokes to 278. Could have gone smaller but a few strokes were added here and there for asthetic purposes, to keep rows nice and tidy.

use threads;;;use IO::Socket;;;@t=map threads->create(sub{$o= IO::Socket::INET->new(qw(PeerAddr perlmonks.org PeerPort 80)) ;print $o "GET /?node_id=$_[0]&displaytype=xml HTTP/1.0\n\n"; local$/;(<$o>=~/title="(\w+\s)/)},$_),9655,6352,297065,138903 ;print$_->join for@t;print$/
I lost five strokes in the beautification. ;) The biggest gain was in making the sub an anonymous inline sub rather than a named one.

Great japh. I always like these ones that grab things off the net.


Dave


"If I had my life to do over again, I'd be a plumber." -- Albert Einstein

Replies are listed 'Best First'.
Re: Re: Re: Just Another Thread Hacker
by benn (Vicar) on Oct 09, 2003 at 11:11 UTC
    Well, if we're golfing...
    use threads;use IO'Socket;print$_->join for map threads-> create(sub{$o=IO'Socket'INET->new('perlmonks.org:80');print$o "GET /?node_id=$_[0]\n\n";local$/;<$o>=~/e>(\w+\s)/},$_),9655 ,6352,297065,138903;print$/
    A wee bit slower (it grabs the full HTML) and not as prettily formatted, but comes in at 207.

    Toodle-pip,
    Ben