"blue berry muffins are not just a snack.... ..they are a way of life"#!/usr/bin/perl # # Word Of The Day Catching Script... # (V0.1) # Joe Higton # # And hey I was half asleep when I wrote this.... # # Gets the word of the day from www.dictionary.com # # use Gtk; use HTTP::Lite; init Gtk; sub msbox{ # Display some info. Nicely. Ish. my ($title, $message) = @_; my $scroller = new Gtk::ScrolledWindow; my $window = new Gtk::Window; my $label = new Gtk::Label; my $button = new Gtk::Button("OK"); my $pack = new Gtk::Packer; $window->set_title($title); $window->set_default_size(400,340); $window->signal_connect( "destroy" => \&Gtk::main_quit); $button->signal_connect( "clicked" => \&Gtk::main_quit); $label->set_justify(left); $label->set_text($message); $scroller->add_with_viewport($label); $pack->add_defaults($scroller,-top,-center,[-fill_x,-fill_y,-expan +d]); $pack->add_defaults($button,-bottom,-center,[-fill_x,-fill_y]); $window->add($pack); $window->show_all(); } $http = new HTTP::Lite; $req = $http->request("http://www.dictionary.com/wordoftheday/") or die "Couldn't retrieve the Word Of The Day."; # Ok grab the important bit of the web page. Handily kept between two +comments. $http->body() =~ /<!-- Begin content -->(.*)<!--End content-->/s; $wod = $1; # Capture the actual word its self from the cunning comment.. $wod =~ /<!-- WOTD="(.*)" -->/; $theword =$1; #Kill that HTML! I actually stole this regex off perlmonks # because I was too bloody tired to think of one of my own at the #time.. $wod =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs; #Fire all that off into a nice window.. msbox("The Word Of The Day IS: $theword",$wod); Gtk->main();
Edit: chipmunk 2001-06-21
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dictionary.com (PLEASE critisise...)
by Mission (Hermit) on Jun 22, 2001 at 00:47 UTC | |
by PsionicMan (Beadle) on Jun 24, 2001 at 06:14 UTC | |
by Draxil (Novice) on Jun 26, 2001 at 17:28 UTC | |
|
Re: Dictionary.com (PLEASE critisise...)
by Hero Zzyzzx (Curate) on Jun 22, 2001 at 05:16 UTC | |
|
Re: Dictionary.com (PLEASE critisise...)
by John M. Dlugosz (Monsignor) on Jun 22, 2001 at 23:43 UTC |