B-Hooks-OP-Check-EntersubForCV
view release on metacpan or search on metacpan
---
abstract: 'Invoke callbacks on construction of entersub OPs for certain CVs'
author:
- 'Florian Ragwitz <rafl@debian.org>'
build_requires:
B::Hooks::OP::Check: 0.19
B::Utils: 0.19
ExtUtils::MakeMaker: 6.42
configure_requires:
B::Hooks::OP::Check: 0.19
B::Utils: 0.19
ExtUtils::Depends: 0
NAME
B::Hooks::OP::Check::EntersubForCV - Invoke callbacks on construction of
entersub OPs for certain CVs
SYNOPSIS
From Perl
sub foo {}
use B::Hooks::OP::Check::EntersubForCV
\&foo => sub { warn "entersub for foo() being compiled" };
foo(); # callback is invoked when this like is compiled
lib/B/Hooks/OP/Check/EntersubForCV.pm view on Meta::CPAN
unregister($_) for delete @CALLBACKS{ map { refaddr $_ } @_ };
return;
}
1;
__END__
=head1 NAME
B::Hooks::OP::Check::EntersubForCV - Invoke callbacks on construction of entersub OPs for certain CVs
=head1 SYNOPSIS
=head2 From Perl
sub foo {}
use B::Hooks::OP::Check::EntersubForCV
\&foo => sub { warn "entersub for foo() being compiled" };
}
$i = 0;
}
foo();
bar();
foo();
BEGIN {
is($i, 2, 'multiple callbacks');
push @id, B::Hooks::OP::Check::EntersubForCV::register($cv, \&entersub_cb);
is($i, 2, 'no callback after multiple registrations');
$i = 0;
}
foo();
bar();
foo();
BEGIN {
is($i, 4, 'multiple callbacks for multiple entersubs');
B::Hooks::OP::Check::EntersubForCV::unregister(pop @id);
$i = 0;
}
foo();
bar();
foo();
B::Hooks::OP::Check::EntersubForCV::unregister(pop @id);
$i = 0;
}
foo();
bar();
foo();
BEGIN {
is($i, 0, 'no callbacks after removing all registers');
}
( run in 2.192 seconds using v1.01-cache-2.11-cpan-9b1e4054eb1 )