You are here iC Home > Perl > Advanced Features in Perl > Monitored Variables

Perl

9.2 Monitored Variables

07.10.2008
9.1 Performance [  up  ] - [ a - z ] - [ search PC ] - [ top ] 9.3 Suppress warnings from external modules

Examples:

Monitoring change events of variables

#!/usr/bin/perl -w
use strict;

use Monitor;

my ($x, %y);

monitor(\$x, 'x');
monitor(\%y, 'y');

$x = 9;

$y{'foo'} = 'bar';

Output

$ ./monitor_var.pl
Wrote   $x ... 9
Wrote   $y{foo} ... bar
Died    $x
Died    %y

Check if any of a focussed hash key is set with one TRUE condition

use MonitorHash;

my %myhash = ();

my @keys = qw( fookey barkey );
pushElems(\@keys);
monitor_elems(\%myhash, 'myhash');

$myhash{'fookey'} = 'anything';

if (monitored_key_is_set('myhash')) {
        print "One of the specific keys is set in the monitored hash.\n";
}

[ Download: MonitorHash.pm ] - [ Download: Monitor.pm ]


Links




Advanced search tips
9.1 Performance [  up  ] - [ top ] 9.3 Suppress warnings from external modules



[ home ] - [ search ] - [ feedback ]

copyright by reto - created with mytexi