-
Notifications
You must be signed in to change notification settings - Fork 29
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
Exclude functions from importing #11
Comments
I'm currently at YAPC, but just as a quick check, does the following work for you?
|
No, it removes my method for some reason:
|
I hit this as well (have a module with a connect() method that is getting clobbered). use autodie qw/ :all -connect /; |
Oh, dang. I agree, In the tradition of short responses, I'm on the way to KiwiFoo right now, but nudging me in 6-7 days time should reach me in a quiet spot. Alternatively, if you fancy a patch to ~ pjf |
I did a bit more poking around and I see what's happening. autodie is doing its work before the user-supplied method is defined which is why unimport is failing. Here's an ugly work-around: #!/usr/bin/env perl
package Foo;
use strict;
use warnings;
INIT {
require autodie;
autodie->import(':all');
autodie->unimport('connect');
}
sub connect {
warn "MY CONNECT!\n";
return;
}
Foo->connect; With that, we're delaying the autodie setup until after the rest of the code has been defined, which allows unimport to work as expected. I'll look at putting together a patch for the -connect syntax. There's no way to have autodie automatically delay it's execution until the current file is compiled, is there? |
It would be nice to have a syntax for importing "all functions except one".
Exporter.pm
does this with '!' syntax, but unfortunately it's already taken byautodie::hints
.How about '-'?
So,
use autodie qw(:all -read)
would import everything exceptread
.This effect is hard to achieve by other means, see https://gist.github.com/2901998 for my attempts to avoid prototype conflicts with a method named
read
.The text was updated successfully, but these errors were encountered: