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 $!;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|