Perl Basics
Introduction to Perl
FAQ's
CGI
Regular Expressions

PC Overview
Cool Stuff
My Modules
Success Stories
Links
Perl in the News
Logos

PC Internals
About
Contact
Handy Logos
What's new

Monitored Variables

tie makes it really convenient to monitor a variable
See also
P-friendly

[ home ] - [ search ] - [ sitemap ]


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

home - feedback - search

$Id: foo.htm,v 1.10 2004/03/11 17:50:01 reto Exp $
© 1998-2004 reto :)