NAME
Tie::Trace - easy print debugging with tie
VERSION
Version 0.03
SYNOPSIS
use Tie::Trace;
my %hash;
tie %hash, "Tie::Trace";
$hash{hoge} = 'hogehoge'; # warn Hash => Key: hoge, Value: hogehgoe at ...
my @array;
tie @aray, "Tie::Trace";
push @array, "array"; # warn Array => Point: 0, Value: array at ...
my $scalar;
tie $scalar, "Tie::Trace";
$scalar = "scalar"; # warn Scalar => Value: scalar at ...
DESCRIPTION
This is usefull for print debugging. Using tie mechanism, you can see sotred value for the specified variable.
If the stored value is scalar/array/hash ref, this can check recursively.
for example;
tie %hash, "Tie::Trace";
$hash{foo} = {a => 1, b => 2}; # warn ...
$hash{foo}->{a} = 2 # warn ...
But This won't care blessed reference or tied value.
OPTIONS
- key => [values/regexs]
-
tie %hash, "Tie::Trace", key => [qw/foo bar/];
It is for hash. You can spedify key name/regex for checking. Not specified/matched keys are ignored for warning.
for example;
tie %hash, "Tie::Trace", key => [qw/foo bar/, qr/x/]; $hash{foo} = 1 # warn ... $hash{bar} = 1 # warn ... $hash{var} = 1 # *no* warnings $hash{_x_} = 1 # warn ...
- value => [contents/regexs]
-
tie %hash, "Tie::Trace", value => [qw/foo bar/];
You can spedify value's content/regex for checking. Not specified/matched are ignored for warning.
for example;
tie %hash, "Tie::Trace", value => [qw/foo bar/, qr/\)/]; $hash{a} = 'foo' # warn ... $hash{b} = 'foo1' # *no* warnings $hash{c} = 'bar' # warn ... $hash{d} = ':-)' # warn ...
- use => [qw/hash array scalar/]
-
tie %hash, "Tie::Trace", use => [qw/array/];
It specify type of variable for checking. As default, all type will be checked.
for example;
tie %hash, "Tie::Trace", use => [qw/array/]; $hash{foo} = 1 # *no* warnings $hash{bar} = 1 # *no* warnings $hash{var} = [] # *no* warnings push @{$hash{var}} = 1 # warn ...
- debug => 'dumper'/coderef
-
tie %hash, "Tie::Trace", debug => 'dumper' tie %hash, "Tie::Trace", debug => sub{my($self, @v) = @_; return @v }
It specify value representation. As default, just print value as scalar. You can use "dumper" or coderef. "dumper" make value show with Data::Dumper::Dumper. When you specify your coderef, its first argument is tied value and second argument is value, it should modify it and return it.
- debug_value => [contents/regexs]
-
tie %hash, "Tie::Trace", debug => sub{my($s,$v) = @_; $v =~tr/op/po/;}, debug_value => [qw/foo boo/];
You can spedify debugged value's content/regex for checking. Not specified/matched are ignored for warning.
for example;
tie %hash, "Tie::Trace", debug_value => [qw/fpp bar/, qr/\)/]; $hash{a} = 'fpp' # warn ... because debugged value is foo $hash{b} = 'foo' # *no* warnings because debugged value is fpp $hash{c} = 'bpp' # warn ... because debugged value is boo
- r => 0/1
-
tie %hash, "Tie::Trace", r => 0;
If r is 0, this won't check recusively. 1 is default.
- caller => number/[numbers]
-
tie %hash, "Tie::Trace", caller => 2;
It effects warning message. default is 0. If you set grater than 0, it goes upstream to check.
You can specify array ref.
tie %hash, "Tie::Trace", caller => [1, 2, 3];
It display following messages.
Hash => Key: key, Value:hoge at filename line 61. at filename line 383. at filename line 268.
AUTHOR
Ktat, <atusi at pure.ne.jp>
BUGS
Please report any bugs or feature requests to bug-tie-debug at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tie-Trace. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Tie::Trace
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
COPYRIGHT & LICENSE
Copyright 2006 Ktat, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.