Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Impress Women II

by koolade (Pilgrim)
on Sep 05, 2001 at 08:36 UTC ( #110217=CUFP: print w/replies, xml ) Need Help??

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
    Nice idea, but I have had no luck, yet, testing it.
    Are you shure, that uri and proxy settings are ok for all?
    A quick read over the soap-module didn't help, so I ask you, would you please explain a bit more?
    BTW: You have to escape the @ for the mailadresses to be changed, right?
    --
    there are no silly questions
    killerhippy

      That's odd...it works for me. What kind of errors does it give you? Does the script die, or does it just not fetch the jokes?

      Actually, you don't need to escape the @ if the address is in single quotes. Oh...you mean in the here-docs? Yeah, that needs to be escaped.

        Hi koolade,
        I had put in one escape too much at line 4. Deleting
        it and keeping the one at line 27 works fine, now.

        Thanx 4 your advice.
        --
        there are no silly questions
        killerhippy
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
    Nice idea, it is very useful for all of us who forget to write a few lines to our g/f or wife. The only thing that i would add to it to be perfect will be a "flowers" sub, so the program will send a request to some flower delivery site in the aniversary date :) ( that would save my life )
    Shadox
      To save your life, brother monk:
      create yourself calendar reminder at calendar.yahoo.com. These guys will send you email reminder. Then, you can email greeting postcard at greetings.yahoo.com.

      What if you do not have net access? When not distracted, how possibly you can forget?....;-)

      pmas
      To make errors is human. But to make million errors per second, you need a computer.

        Cough. sparks.com - I "worked" there a while ago. They have reminder systems and a history feature to make sure you don't get same card twice... :)

        ----
        Zak
Re: Impress Women II
by vroom (His Eminence) on Sep 11, 2001 at 21:50 UTC
    Cool, I've been enlisted to set up a word(s) of the day mailer for my female friend studying for the GRE.

    This weekend I'm supposed to teach her Everything programming basics so she can update the site I made for the college group we were both a part of last year. Fun. Fun.

    vroom | Tim Vroom | vroom@blockstackers.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://110217]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (1)
As of 2022-07-02 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (103 votes). Check out past polls.

    Notices?