-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add feature to pass additional arguments on to coderef #3
Comments
Not the author, but I think you can achieve that with the use of the |
I've never used The documentation of
This issue is only about how to conveniently save that information in (2). Without that I need to write my $original_max_redirect = $ua->max_redirect;
my $guard = guard { $ua->max_redirect($original_max_redirect) } # will restore original value
$ua->max_redirect(0); # temporarily
... This could be shortened by passing the original value along. How could |
Not at all; it's about wrapping up extra arguments in a closure for re-use. You can write the closure yourself, but This is fairly simple; does this do what you're looking for?
|
Yeah, this is the obvious plain version. I thought I could save that extra line and it might be a neat feature of Scope::Guard anyway as Sorry, but how would the shorter code look like using |
instead of
you could do:
|
Thank you for this great module. I've written minimal versions of this multiple times and have just found this concise solution on CPAN! 👍
Would you mind adding a feature that you can provide additional arguments that get passed on to the provided coderef?
The difference to
is obviously the execution time of
$foo
etc. I have a long livingLWP::UserAgent
object and need to temporarily set itsmax_redirect
to 0. I'd love to write this:As far as I studied your code no existing code could be using any additional arguments and they could easily stored in
@$self
.I'd send a PR if you consider adding this feature.
The text was updated successfully, but these errors were encountered: