Permalink
Browse files

allow hash or hashref for opts. This is for symmetry with SingleDim

  • Loading branch information...
1 parent 597a8fe commit 76a0c99d9dfdffef031f05f749ed992ae5b94369 @jberger committed May 9, 2012
Showing with 10 additions and 7 deletions.
  1. +10 −7 lib/PerlGSL/Integration/MultiDim.pm
@@ -17,16 +17,19 @@ our @EXPORT_OK = ( qw/
/ );
sub int_multi {
- my $opts;
- if (eval { ref $_[-1] eq 'HASH' }) {
- $opts = pop;
+ croak "int_multi requires 3 arguments, aside from an options hash(ref)"
+ unless @_ >= 3;
+
+ my ($sub, $xl, $xu) = (shift, shift, shift);
+
+ my %opts;
+ if (@_) {
+ %opts = ref $_[0] ? %{shift()} : @_;
}
- $opts->{calls} ||= 500000;
- croak "int_multi requires 3 arguments, aside from an options hashref"
- unless @_ == 3;
+ $opts{calls} ||= 500000;
- my $ret = c_int_multi(@_, $opts->{calls});
+ my $ret = c_int_multi($sub, $xl, $xu, $opts{calls});
return wantarray ? @$ret : $ret->[0];
}

0 comments on commit 76a0c99

Please sign in to comment.