ARRAY|1321|1465|1573
CODE|536|551|566
FSA::State|20|30|40
GLOB|953|954|954
HASH|274|313|352
REF|566|798|994
REF-ARRAY|158|272|350
REF-CODE|97|142|187
REF-FSA::State|56|84|112
REF-HASH|90|129|168
REF-Regexp|12|18|24
Regexp|12|18|24
SCALAR|10156|10303|10447
####
package Test::Gladiator;
use Scalar::Util qw(weaken);
use Cwd;
use File::Spec;
sub new {
my $class = shift;
my $file = File::Spec->catfile( getcwd(), 'gladiator_output.txt' );
open( my $out, '>', $file ) or die "Cannot create $file: $!";
my $self = { counting => {}, out_h => $out };
return bless $self, $class;
}
sub DESTROY {
my $self = shift;
close( $self->{out_h} ) or die $!;
}
sub show_accounting {
my $self = shift;
my $out = $self->{out_h};
foreach my $key ( sort( keys( %{ $self->{counting} } ) ) ) {
print $out $key, '|', join( '|', @{ $self->{counting}->{$key} } ),
"\n"
if (
$self->{counting}->{$key}->[1] > $self->{counting}->{$key}->[0] );
}
}
sub count_leaks {
my $self = shift;
my $total = 0;
foreach my $key ( keys( %{ $self->{counting} } ) ) {
my $last = $#{ $self->{counting}->{$key} };
$total++
if ( $self->{counting}->{$key}->[$last] >
$self->{counting}->{$key}->[ $last - 1 ] );
}
return $total;
}
sub increment_count {
my $self = shift;
my $current = shift;
weaken($current);
foreach my $key ( keys( %{$current} ) ) {
if ( exists( $self->{counting}->{$key} ) ) {
push( @{ $self->{counting}->{$key} }, $current->{$key} );
}
else {
$self->{counting}->{$key} = [ $current->{$key} ];
}
}
}
1;
####
ARRAY|1321|1465|1573
CODE|536|551|566
GLOB|953|954|954
HASH|274|313|352
SCALAR|10156|10303|10447