Re: Dealing with a STRANGE API
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxx
- Date: 6 Oct 2006 23:12:19 GMT
Ignoramus7272 <ignoramus7272@xxxxxxxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
I am using PayPal API class
Business::PayPal::API::TransactionSearch
It uses some very weird code
Indeed. Snipped.
that is, it returns a hash when there is error, and a list reference
when there is not.
I am bewildered, just how can I get this result into one variable and
then figure out if I am dealing with success (so that I can print
results from the list reference), or failure (so that I can print a
hash element error message).
Any idea? I tried obvious things like setting a scalar to the result
of this function, and could not.
Untested:
my @mystery = $obj->meth_from_hell( ...);
if ( @mystery == 1 ) {
my @array = @{ $mystery[ 0] };
# normal processing
} else {
my %hash = @mystery;
# error
}
The distinction is reliable because the hash returns an even number of
scalars.
You shouldn't have to do this.
Anno
.
- Follow-Ups:
- Re: Dealing with a STRANGE API
- From: Ignoramus7272
- Re: Dealing with a STRANGE API
- References:
- Dealing with a STRANGE API
- From: Ignoramus7272
- Dealing with a STRANGE API
- Prev by Date: Re: Unit-testing and mock objects
- Next by Date: Re: Can perl test for .mp3 file?
- Previous by thread: Dealing with a STRANGE API
- Next by thread: Re: Dealing with a STRANGE API
- Index(es):
Relevant Pages
|