We are integrating with the Yahoo storefront for some customers, and I am
having a problem accessing some of the data elements within the data stream.

This is a dump of the raw information dumped by my program:

Bill-Address1 = 5575 North Service Road
Bill-Address2 = 4th Floor
Bill-City = Burlington
Bill-Country = US United States
Bill-Email = [EMAIL PROTECTED]
Bill-Firstname = Carlin
Bill-Lastname = Anderson
Bill-Name = Carlin Anderson
Bill-Phone = 905-111-2222
Bill-State = OH
Bill-Zip = 13433
Card-Expiry = 4/2003
Card-Name = Visa
Card-Number = 4111111111111111
Comments = 
Coupon-Description = 
Coupon-Value = 
Currency = USD
Date = Fri Oct 19 15:07:35 2001 GMT
Gift-Wrap = on
Gift-Wrap-Charge = 15
Gift-Wrap-Message = A test gift message
ID = edig-536
Item-Code-1 = 13-330039
Item-Count = 1
Item-Description-1 = Home Audio System Adapter Cable
Item-Id-1 = 13-830053
Item-Quantity-1 = 3
Item-Taxable-1 = YES
Item-Unit-Price-1 = 4.95
Item-Url-1 = http://store.yahoo.com/
Numeric-Time = 1003504055
Ship-Address1 = 5575 North Service Road
Ship-Address2 = 4th Floor
Ship-City = Burlington
Ship-Country = US United States
Ship-Firstname = Carlin
Ship-Lastname = Anderson
Ship-Name = Carlin Anderson
Ship-Phone = 905-111-2222
Ship-State = OH
Ship-Zip = 13433
Shipping = Next Day Air
Shipping-Charge = 19.95
Space-Id = 
Store-Id = edig
Store-Name = eDigital
Tax-Charge = 0.00
Total = 49.80

And here is the relevant segment of my program:

#!/usr/perl5/bin/perl

require 5.001;
use strict;
use CGI;
use DBI;
use File::Copy;

if ($ENV{'REQUEST_METHOD'} ne "POST") {
    die("Expecting a POST, bailing");
}

my $o;
read(STDIN,$o,$ENV{'CONTENT_LENGTH'});

my %o;
for (split(/&/,$o)) {
    $_ =~ s/\+/ /g;
    my($key,$val) = split(/=/,$_,2);
    for ($key,$val) {
        $_ =~ s/%([0-9a-fA-F][0-9a-fA-F])/chr(hex($1))/ge;
    }
    $o{$key} = $val;
}

my @items;
my $i;
for ($i=1; $i<=$o{'Item-Count'}; $i++) {
    push(@items,{map {($_,$o{"Item-$_-$i"})} qw(Id Code Quantity Unit-Price
Description Url)});
}
open(RAW,">/tmp/yahoo-order.raw");
for (sort keys %o) {
    print RAW "$_ = $o{$_}\n";
}
close(RAW);

&handle_order(\%o,@items);

# A successful delivery is indicated by a good HTTP result code.
print "Status: 200 OK\n";
print "\n";
exit(0);


######################################################################
# Replace this function with something that does what you want
#   $info gets a hash ref of all the order fields, like Ship-Name.
#   @items gets an array of hash refs, one for each item.

sub handle_order {
    my($info,@items)=@_;
my $del;
my $sec;
my $min;
my $hour;
my $mday;
my $mon;
my $year;
my $wday;
my $yday;
my $isdat;
my $tmp;

$del = "\xAC";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdat) = localtime(time);
$year = $year + 1900;
$mon = $mon + 1;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
    open(OUT,">/tmp/$year$mon$mday$hour$min$sec$info->{ID}.txt");
    print OUT
"H",$info->{ID},$del,$del,$info->{Date},$del,$hour,":",$min,":",$sec,$del,"C
RCD",$del,"EDG",$del,$info->{'Shipping-Charge'},$del;
    if ($info->(Gift-Wrap) = "on"){
        print OUT
"GIFTWRAP",$del,$info->('Gift-Wrap-Message'),$del,$info->('Gift-Wrap-Charge'
),$del,$del,$del,$del;
        }
    else {
    print OUT $del,$del,$del,$del,$del,$del;
    }
    print OUT
$info->{'Shipping'},$del,$del,"N",$del,"N",$del,"N",$del,$del,"\n";
    print OUT
"H",$info->{'Ship-Name'},$del,$del,$info->{'Ship-Address1'},$del,$info->{'Sh
ip-Address2'},$del,$info->{'Ship-City'},$del,$info->{'Ship-State'},$del,$inf
o->{'Ship-Country'},$del,$info->{'Ship-Zip'},$del,$info->{'Ship-Phone'},$del
,"\n";
    print OUT
"H",$info->{'Bill-Name'},$del,$del,$info->{'Bill-Address1'},$del,$info->{'Bi
ll-Address2'},$del,$info->{'Bill-City'},$del,$info->{'Bill-State'},$del,$inf
o->{'Bill-Country'},$del,$info->{'Bill-Zip'},$del,$info->{'Bill-Phone'},$del
,$info->{'Bill-Email'},"\n";
    print OUT
"H",$info->{'Tax-Charge'},$del,$info->{'Total'},$del,$info->{'Card-Name'},$d
el,$info->{'Card-Number'},$del,$info->{'Card-Expiry'},"\n";

    close(OUT);
}


My problem is when I try to access the Gift-Wrap elements, the program just
dies where I after the first print to OUT.  I have tried everything I know
of, but I am relatively new to this.  Any help would be greatly appreciated.


Carlin Anderson
Sr. Software Engineer
APL Direct Logistics
1301 Riverplace Blvd, Suite 530
Jacksonville, FL  32207
904-858-4754           direct
904-616-6542           cell phone, pager
[EMAIL PROTECTED]
[EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to