My dad came to visit and I was showing him the internet so I never have to write a letter again(email)! I was showing him how to bid on things on ebay. We placed a bid on a coin he wanted, but he was driving me crazy checking it every five minutes. I decided to take the email feature from my adminmail.pl(posted already) program and the webpage grabbing feature of my fatbrain.pl(also posted) program. I turned it into the program you see bellow to tell me if I lose the high bid. I set it in cron to check every five minutes and we were able to relax the rest of the weekend. I never thought perl would improve my relationship with my dad, but it did! What other programming language can say that! Since I had the code written and a pager that accepts email it took about five minutes to setup. I am sure my fellow monks will come up with creative ways to use email pagers!

There is a line in the code that generates an error. Something like "System cannot find file." The line is marked bellow. The program works, but I was just curious.

use strict; use Net::SMTP; use LWP::UserAgent; my $from = 'ergowolf07@home.com'; my @recip_list = ('XXXXXXX@skytel.com'); my $smtp_host = "mail"; # This line generates and error my $smtp = Net::SMTP->new($smtp_host, Timeout => 30) || die "Can't con +nect to $smtp_host.\n"; $smtp->mail($from) || die "cannot mail from.\n\n"; $smtp->recipient(@recip_list); $smtp->data(); $smtp->datasend("To:\tEbay info\n"); my $page = 'http://cgi.ebay.com/aw-cgi/eBayISAPI.dll?ViewItem&item=XXX +XXXXXXX'; my $ua = new LWP::UserAgent; my $req = new HTTP::Request GET => $page; my $string = $ua->request($req)->as_string; if ($string =~ m/tmonte/g) { $smtp->datasend("you are the high bidder.\n"); } else { $smtp->datasend("You are no longer the high bidder.\n"); } $smtp->dataend; $smtp->quit;

Replies are listed 'Best First'.
RE: Ebay, my pager and my dad
by Adam (Vicar) on May 01, 2000 at 19:55 UTC
    Use or instead of the double pipe ||. or is of a lower presedence, and I'd wager that this is part of the problem.
      This is a good point. I will test it. If my memory is correct you are supposed to use || for numeric expressions and or for words. If I had a vote left today I would give you a point. :)

        || and "or" (as well as && and "and") have nothing to do with numeric vs strings. They both are simple tests, the only difference is in their priority: the "words" ("and" and "or") are of a lower priority than the ones a C programmer would know (&& and ||).

        'or' is safer to use in some cases because it almost guarantees that everything to the left of it binds tighter (gets evaluated as a single expresion) and *then* gets tested. It's really on a case by case basis. A good and consistent use of parenthesis can often prevent making such decisions, as it removes the the precedence ambiguity.

        Sorry, but your memory is incorrect here. :)

        I think you're probably confusing the difference between or and || with the difference between, say, lt and <. There is no relationship between the two differences.

        or and || act the same (they have the same short-circuit behavior), but or has a much lower precedence--meaning that you can use it after list operators without using parantheses. Read perlop for more details.

RE: Ebay, my pager and my dad
by btrott (Parson) on May 01, 2000 at 23:59 UTC
    I don't think whether the OP uses or or || is the issue, actually. I don't think it'll make a difference at all.

    ergowolf: could you post the actual error message you're getting, rather than just an approximation of it? Could it have something to do w/ Net::Config, I wonder? That's just a *complete* guess. :)

    FWIW, I'm not getting the error message.

RE: Ebay, my pager and my dad
by Anonymous Monk on May 02, 2000 at 04:00 UTC
    You know that we all secretly hope to get an alpha numeric pager that doesn't support email so that we can use a text to speech converting :)