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)}]; }

—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot

In reply to Net::UPS causing undefined array ref error by bradcathey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.