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

In reply to Impress Women II by koolade

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.