bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians,
Just tried to run what I thought would be a simple little module: Net::UPS which returns UPS services, rates, and enroute times. But I getting this lovely error:
Error executing run mode 'e': Can't use an undefined value as an ARRAY reference at /usr/share/perl5/Net/UPS.pm line 237
I'm confused what might be causing this. Ideas?
My code snippet (99% of it right out of the CPAN docs)
my $zip_to = "60446"; my $zip_from = "60187"; my $weight = 2.26"; my $package = Net::UPS::Package->new(); $package -> weight($weight); #dumped here my $services = $ups->shop_for_rates($zip_from, $zip_to, $package); while (my $service = shift @$services ) { $message .= sprintf("%-22s => \$.2f", $service->label, $service->t +otal_charges); if ( my $days = $service->guaranteed_days ) { sprintf("(delivers in %d day%s)\n", $days, ($days > 1) ? "s" : + ""); } else { "\n"; } }
Results of Data::Dumper:
$VAR1 = '60446'; $VAR2 = '43214'; $VAR3 = bless( [ undef, undef, undef, undef, undef, undef, '2.26' ], 'Net::UPS::Package' );
Last line (237) of this snip from UPS.pm is producing error message
sub shop_for_rates { my $self = shift; my ($from, $to, $packages, $args) = @_; unless ( $from && $to && $packages ) { croak "shop_for_rates(): usage error"; } unless ( ref $from ) { $from = Net::UPS::Address->new(postal_code=>$from); } unless ( ref $to ) { $to = Net::UPS::Address->new(postal_code=>$to); } unless ( ref $packages eq 'ARRAY' ) { $packages = [$packages]; } $args ||= {}; $args->{mode} = "shop"; $args->{service}||= "GROUND"; return [sort{$a->total_charges <=>$b->total_charges} @{$self->requ +est_rate($from, $to, $packages, $args)}]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::UPS causing undefined array ref error
by grep (Monsignor) on Dec 19, 2006 at 02:33 UTC | |
by bradcathey (Prior) on Dec 19, 2006 at 03:09 UTC | |
by grep (Monsignor) on Dec 19, 2006 at 04:21 UTC | |
|
Re: Net::UPS causing undefined array ref error
by Popcorn Dave (Abbot) on Dec 19, 2006 at 04:47 UTC | |
|
Re: Net::UPS causing undefined array ref error
by zentara (Cardinal) on Dec 19, 2006 at 19:05 UTC | |
by bradcathey (Prior) on Dec 19, 2006 at 22:03 UTC | |
by Anonymous Monk on Mar 14, 2007 at 18:48 UTC | |
by mltsy (Initiate) on May 03, 2007 at 14:02 UTC | |
by marto (Cardinal) on May 03, 2007 at 14:12 UTC |