A sequel to this node: Impress Women, and my response: Re: Impress Women that I thought I'd share....
I've had a small perl script running each morning to send an email to my wife so she gets mail from me frequently. I had the script capturing the output of "fortune" each time so the email would have a little bit of variety, but lately got into reading a SOAP::Lite tutorial at http://www.perl.com/pub/a/2001/01/soap.html so I thought I'd implement something using that instead. My wife really doesn't understand a lot of the computer-sci related jokes output by "fortune", and even some I find really dry. Luckily I ran across a SOAP service that would return random jokes, and was able to use that pretty nicely.
So here's the code in case anyone's interested in wooing their significant other with their geekiness ;) Simple, but effective in brightening up another's workday.
#!/usr/bin/perl -w use strict; use SOAP::Lite; my $addr = 'wife@emailaddress.com'; my $soap = SOAP::Lite ->uri('urn:vgx-joke') ->proxy('http://services.xmltoday.com/vx_engine/soap-trigger.p +perl') ->on_fault( sub { my($soap, $res) = @_; die ref $res ? $res->faultdetail : $soap->transport->s +tatus, "\n"; } ); my $res; eval { $res = $soap->JokeOfTheDay()->result; }; my ($subject, $message); if (!$@ && $res->{'title'} && $res->{'text'}) { $subject = "My daily email: $res->{'title'}"; $message = $res->{'text'}; } else { $subject = 'My daily email'; $message = "Sorry, I can't think of any jokes today. :("; } open(MAIL, "| /usr/sbin/sendmail $addr") or die $!; print MAIL<<THE_END; From: my@address To: $addr Subject: $subject <sappy message .... > $message THE_END close(MAIL) or die $!;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Impress Women II
by khippy (Scribe) on Sep 05, 2001 at 16:41 UTC | |
by koolade (Pilgrim) on Sep 06, 2001 at 03:51 UTC | |
by khippy (Scribe) on Sep 06, 2001 at 11:29 UTC | |
|
Re: Impress Women II
by one4k4 (Hermit) on Sep 05, 2001 at 23:57 UTC | |
|
Re: Impress Women II
by shadox (Priest) on Sep 06, 2001 at 01:33 UTC | |
by pmas (Hermit) on Sep 06, 2001 at 05:48 UTC | |
by zakzebrowski (Curate) on Sep 06, 2001 at 20:41 UTC | |
|
Re: Impress Women II
by vroom (His Eminence) on Sep 11, 2001 at 21:50 UTC |