Skip to content

Instantly share code, notes, and snippets.

@dr-kd
Created November 18, 2015 05:02
Show Gist options
  • Save dr-kd/f820b2c53e792293206f to your computer and use it in GitHub Desktop.
Save dr-kd/f820b2c53e792293206f to your computer and use it in GitHub Desktop.
package Some::Object;
...;
use Devel::Cycle;
# Devel::Cycle assumes you're happy with things going to STDOUT.
no warnings 'redefine';
sub Devel::Cycle::_do_report {
my $counter = shift;
my $path = shift;
warn "Cycle ($counter):\n";
foreach (@$path) {
my ($type,$index,$ref,$value,$is_weak) = @$_;
printf( STDERR "\t%30s => %-30s\n",($is_weak ? 'w-> ' : '')
.Devel::Cycle::_format_reference($type,$index,$ref,0)
, Devel::Cycle::_format_reference(undef,undef,$value,1));
}
}
sub DESTROY {
my ($self) = @_;
print STDERR "##### DESTROY #####\n\n";
my $user = $self->_get_config->{current_user};
return unless $user;
my $ref = tied %$user;
return unless $ref;
print STDERR "\n\n\n##### CYCLE #####\n\n";
find_cycle($ref);
print STDERR "##### WEAK CYCLE #####\n\n\n";
find_weakened_cycle($ref);
print STDERR "##### END #####\n\n\n";
my $x = 0;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment