http://qs321.pair.com?node_id=110217

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 $!;