Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Don't panic! (Hitch hikers' facility)

by larsen (Parson)
on May 29, 2001 at 00:33 UTC ( #83785=CUFP: print w/ replies, xml ) Need Help??

I know. Forgot my towel on 25th. This is an attempt to apologize :). A medium snippet (or a little program, if you prefear) to dig through the Galactic Guide.

Update: Another good Guide:

Update: Following jepri's advice, topic can come from command-line.

#!/usr/bin/perl use strict; use LWP::Simple; use HTML::Parser; my $in_article_body = 0; my $colin = HTML::Parser->new( start_h => [sub { my $self = shift; my ($tagname, $attr) = @_; if ($tagname eq "div" && $attr->{class} eq 'article') { $in_article_body = 1;; } }, "self, tagname, attr"], end_h => [sub { my $self = shift; my ($tagname) = @_; if ($tagname eq "div" && $in_article_body) { $in_article_body = 0; } }, "self, tagname"], text_h => [sub { my $self = shift; my ($origtext) = @_; print $origtext if $in_article_body; }, "self, text"]); my $topic = $ARGV[0] || 'perl'; my $url = " +rchval=$topic"; my $string = get( $url ); # It works like Google's "I'm feeling lucky"-mode if ($string =~ /1\. <a href="([^"]*)/ ) { my $new_url = "$1"; my $text = get( $new_url ); $colin->parse( $text ); } else { print "There aren't pages about $topic\n"; }

Comment on Don't panic! (Hitch hikers' facility)
Download Code
Replies are listed 'Best First'.
Re: No panic! (Hitch hikers' facility)
by jepri (Parson) on May 29, 2001 at 10:00 UTC
    That's a nice program. I was confused for a while because no matter what I typed in at the command line, it printed out the geek code. For a moment I thought that was the joke.

    A line like $topic = $ARGV[0] ? shift @ARGV : 'perl'; would give it nice command line functionality. Then I could include it in shell scripts and the like :)

    I didn't believe in evil until I dated it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://83785]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2015-11-27 16:59 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (731 votes), past polls