Example 1
package Debug;
use Attribute::Handlers;
use Data::Dumper;
our @monitoring;
sub Monitored : ATTR(SCALAR) {
my ( $package, $symbol, $referent, $attr, $data, $phase ) = @_;
push @monitoring, $referent;
}
sub report {
foreach my $var (@monitoring) {
print Dumper ${$var};
}
}
package main;
my Debug $test1 : Monitored = "test1";
my Debug $test2 : Monitored = "test2";
Debug->report;
$test1 = ['Houston'];
Debug->report;
$test2 = {'pm' => 1};
Debug->report;
$VAR1 = 'test1';
$VAR1 = 'test2';
$VAR1 = [
'Houston'
];
$VAR1 = 'test2';
$VAR1 = [
'Houston'
];
$VAR1 = {
'pm' => 1
};