#!/usr/bin/perl use v5.12; use strict; use warnings; use Data::Dumper; package SpyHash; use Tie::Hash; # for Tie::StdHash use Carp qw( carp ); our @ISA=qw( Tie::StdHash ); sub STORE{ my ($self,$key,$value)=@_; $key=~/^CH?LD$/ and carp "Assign to key $key"; return $self->SUPER::STORE($key,$value); } sub DELETE { my ($self,$key)=@_; $key=~/^CH?LD$/ and carp "Delete key $key"; return $self->SUPER::DELETE($key); } 1; package main; sub info { my $where=shift; print $where,": ",Dumper($SIG{'CHLD'}),"\n"; } info('start'); tie %SIG,'SpyHash'; info('after tie'); $SIG{'CHLD'}=sub { 'just a dummy' }; # this line should be reported info('after set handler'); require Net::DNS; # Any module messing with $SIG{'CHLD'} should be reported from here info('after require'); Net::DNS->import(); # ... or here info('after import'); # For some extra paranoia, pretend to do some work with Net::DNS: my $dns=Net::DNS::Resolver->new(); info('after creating instance'); my $reply=$dns->search('localhost'); info('after resolving localhost'); $reply=$dns->search('no.such.host.anywhere.invalid.'); info('after resolving junk');