nzsvz9 has asked for the wisdom of the Perl Monks concerning the following question:

Well I've looked a lot of places and can't find any code out there to do the UPS OnLine Rate stuff in perl. UPS provides one in java (that I can't even get to compile ... thank you very much Sun Microsystems and UPS) and one in VBS (cold shiver).

I'd really like one in perl ... wouldn't we all?

The old Business::UPS module did this for their old rating service, and even contacted Justin Wheeler, but he said he didn't have a new one ... and that trail died.

So like a good hack, I started down that road myself. Only to find lots and lots of bumps.

The LPW::UserAgent code does not do HTTPS - at least as far as I can tell, and the UPS stuff is all HTTPS so I'm stuck.

It would seem I need to install Net::SSL but that keeps coming back with Crypt::SSLeay (from CPAN as it does not appear to be available from ppm at ActiveState) which is just confusing the heck out of me ... and I'm having no luck installing it.

I'm doing development on a Windows based machine, with ActiveState build 635.

Bad day, bad day, bad day.

Any help would be welcome.

Replies are listed 'Best First'.
Re: UPS Online over HTTPS
by Popcorn Dave (Abbot) on Jul 17, 2003 at 16:57 UTC
    It can be done and I've actually done it. What I did was to download the rate pages and then parsed them to get the pertinant information out.

    This may not be the greatest code as I wrote it a while ago, but see if this helps.

    #!/usr/bin/perl use strict; my $resfile = 'ground.txt'; my $comfile = 'grndcomm.txt'; my $zonefile='delzone.txt'; my @res; my @com; my @zone; &buildrates; &buildzones; sub buildrates{ my $line; open FH, $resfile; while ($line = <FH>){ my ($index, $z2, $z3, $z4, $z5, $z6, $z7, $z8)= split(',',$line); $res[$index]= [$z2,$z3,$z4,$z5,$z6,$z7,$z8]; } close FH; open FH, $comfile; while ($line = <FH>){ my ($index, $z2, $z3, $z4, $z5, $z6, $z7, $z8)= split(',',$line); $res[$index]= [$z2,$z3,$z4,$z5,$z6,$z7,$z8]; } close FH; } sub buildzones{ my ($x, $y, $line); my $i=0; open FH, $zonefile; while ($line = <FH>){ ($x,$y) = split(',',$line); if (length($x)<=3){ $zone[$x]=$y } else{ (my $temp, $x) = split('-',$x); for ($temp..$x){ $zone[$_]= $y; } } } }

    When I wrote this, I just grabbed the files off the UPS website. I believe that they were available in a plain text format, but it's been a while so I don't remember for sure.

    Hopefully this will help in some way. :)

    There is no emoticon for what I'm feeling now.

      If the files were on the website, you could always add code to have LWP::Useragent go and get them. I can't imagine that those files would be stashed on the secure server.

      </ajdelore>

        You're right. I realized after I thought about it a bit that the poster was asking about doing that over a secure server, but what I did should work.

        I wrote that code about a year ago and hadn't discovered the LWP library at the time. Using LWP and mirroring to check for newer versions would probably be the way to go. And the LWP suggestion is going to get implemented as soon as I get a bit of free time. Thanks for that!

        There is no emoticon for what I'm feeling now.

Re: UPS Online over HTTPS
by antirice (Priest) on Jul 18, 2003 at 00:50 UTC

    I am not at all a pro with ActiveState. In fact, I don't even use windows for perl programming. Now that we have that out of the way:

    openssl is required for Crypt::SSLeay to work. You can build it with pretty much any WIN32 C compiler, although some editing may be required.

    Of course, there's a note within the module's pod:

    [!!! NOTE for Win32 users, few people seem to be able to build W Crypt::SSLeay successfully on that platform. You don't need I to because ActiveState has already compiled it for you, N and is available for their perl builds 618 & 522 as a ppm 3 install. It may also be available for their latest build. 2 For problems with this, please contact ActiveState. !!! Please see http://www.activestate.com/

    As luck would have it, having looked to see if there's a ppm available, I discovered that there isn't. :-/

    Update: Using the oracle, I've found a place that offers a Crypt::SSLeay ppm and it is available through this link provided in this post.

    Hope this helps.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1