| Server IP : 23.254.227.96 / Your IP : 216.73.216.183 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/perl5/vendor_perl/B/Hooks/EndOfScope/PP/ |
Upload File : |
# Implementation of a pure-perl on_scope_end for perls > 5.10
# (relies on Hash::Util:FieldHash)
package # hide from pause
B::Hooks::EndOfScope::PP::FieldHash;
use strict;
use warnings;
our $VERSION = '0.21';
use Tie::Hash ();
use Hash::Util::FieldHash 'fieldhash';
# Here we rely on a combination of several behaviors:
#
# * %^H is deallocated on scope exit, so any references to it disappear
# * A lost weakref in a fieldhash causes the corresponding key to be deleted
# * Deletion of a key on a tied hash triggers DELETE
#
# Therefore the DELETE of a tied fieldhash containing a %^H reference will
# be the hook to fire all our callbacks.
fieldhash my %hh;
{
package # hide from pause too
B::Hooks::EndOfScope::PP::_TieHintHashFieldHash;
our @ISA = ( 'Tie::StdHash' ); # in Tie::Hash, in core
sub DELETE {
my $ret = shift->SUPER::DELETE(@_);
B::Hooks::EndOfScope::PP::__invoke_callback($_) for @$ret;
$ret;
}
}
sub on_scope_end (&) {
$^H |= 0x020000;
tie(%hh, 'B::Hooks::EndOfScope::PP::_TieHintHashFieldHash')
unless tied %hh;
push @{ $hh{\%^H} ||= [] }, shift;
}
1;