Subject: | coderef from magic scalar |
Date: | Fri, 26 Aug 2011 11:00:02 +1000 |
To: | bug-File-Locate [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
In File::Locate 0.62 on recent i386 debian perl 5.12.4, locate() doesn't
notice a callback coderef if it comes from a tied scalar.
foo.pl below prints nothing, where I expect it to reach the my_func()
and print.
I suspect locate() should run SvGETMAGIC() or whatever equivalent before
checking SvROK for a coderef.
use strict;
use File::Locate;
{
package MyTie;
sub TIESCALAR {
my $class = shift;
return bless {@_}, $class;
}
sub FETCH {
return \&my_func;
}
sub my_func {
my ($filename) = @_;
print "my_code: $_\n";
exit 0;
}
}
my $coderef;
tie $coderef, 'MyTie';
# print $coderef,"\n";
locate ("*.pm", "/var/cache/locate/locatedb", $coderef);