strat has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I come here with a simple problem: I need to add a timeout to a method call, and now think about the best way how to 'say' it. Well, I don't want to use named parameters for such a simple task.
Here the original call without timeout:
my $success = $deployer->extend_order_lease( $order, $end_date );
Well, I wrote a little sub which deals with the timeout, and called it like the following:
Number 1:
my $success = $self->do_method_with_timeout( $timeout, $deployer => extend_order_lease => ( $order, $end_date ) );
The => looks a little bit like the -> from the original call, but there are no pairs.
Number 2:
my $success = $self->do_method_with_timeout( $timeout, $deployer, 'extend_order_lease', $order, $end_date );
But there you don't see what belongs together...
Number 3:
my $success = $self->do_sub_with_timeout( sub { return $deployer->extend_order_lease( $order, $end_date ); }, $timeout, );
But the longer I look at those ways, the less I like them...
Please, could you help me and tell me how you would write it?
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Style - how to give class method call as parameter
by Corion (Patriarch) on Jun 26, 2012 at 13:47 UTC | |
by strat (Canon) on Jun 26, 2012 at 18:23 UTC | |
Re: Style - how to give class method call as parameter
by dsheroh (Monsignor) on Jun 26, 2012 at 14:31 UTC | |
by strat (Canon) on Jun 26, 2012 at 18:14 UTC | |
Re: Style - how to give class method call as parameter
by Athanasius (Archbishop) on Jun 26, 2012 at 13:40 UTC | |
by Boldra (Deacon) on Jun 26, 2012 at 13:44 UTC | |
by choroba (Cardinal) on Jun 26, 2012 at 13:50 UTC | |
Re: Style - how to give class method call as parameter
by NetWallah (Canon) on Jun 27, 2012 at 03:11 UTC | |
Re: Style - how to give class method call as parameter
by Schnufftlapper (Initiate) on Jun 26, 2012 at 13:30 UTC |