Devel-Probe

 view release on metacpan or  search on metacpan

lib/Devel/Probe.pm  view on Meta::CPAN


The C<argument> field is optional and its default value is undefined. Possible
values are any Perl scalar.  If present, it will be passed to the C<trigger>
callback as the third argument.

=back

=head1 EXAMPLE

This will invoke the callback defined with the call to C<trigger()>, the first
time line 21 executes, taking advantage of C<PadWalker> to dump the local
variables.  After that first execution, that particular probe will not be
triggered anymore.  For line 22, every time that line is executed the probe
will be triggered.

    # line 1
    use 5.18.0;
    use Data::Dumper qw(Dumper);
    use PadWalker qw(peek_my);
    use Devel::Probe;

    Devel::Probe::trigger(sub {
        my ($file, $line) = @_;
        say Dumper(peek_my(1)); # 1 to jump up one level in the stack;
    });

    my %config = (
        actions => [
            { action => 'define', file => __FILE__, lines => [ 22 ] },

lib/Devel/Probe.pm  view on Meta::CPAN

        $count++;                                   # line 22
        my $something_inside_the_loop = $count * 2; # line 23
        sleep 5;
    }
    Devel::Probe::disable();

As another example, you can pass a custom argument to the trigger callback:

    # line 1
    use 5.18.0;
    use PadWalker qw(peek_my);
    use Devel::Probe;

    Devel::Probe::trigger(sub {
        my ($file, $line, $interesting_var_name) = @_;
        say "$interesting_var_name: " . ${ peek_my(1)->{$interesting_var_name} };
    });

    my %config = (
        actions => [
            { action => 'enable' },



( run in 0.547 second using v1.01-cache-2.11-cpan-05444aca049 )