The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

NAME

Devel::OptreeDiff - Produces diffs of optrees

SYNOPSIS

use Devel::OptreeDiff 'fmt_optree_diff';
use Data::Dumper 'Dumper';
print map "$_\n",
fmt_optree_diff( sub { print @_ or die $! },
sub { print @_ } ) );
- /leavesub/lineseq/nextstate*print
+ /leavesub/lineseq/nextstate*null
+ .op_flags = 4
+ .op_private = 1
+ .op_targ = 0
+ /leavesub/lineseq/nextstate*null/or
+ .op_flags = 4
+ .op_other = 0
+ .op_private = 1
+ .op_targ = 0
+ /leavesub/lineseq/nextstate*null/or/print
- /leavesub/lineseq/nextstate*print/pushmark
+ /leavesub/lineseq/nextstate*null/or/print/pushmark
- /leavesub/lineseq/nextstate*print/pushmark*rv2av
+ /leavesub/lineseq/nextstate*null/or/print/pushmark*rv2av
- /leavesub/lineseq/nextstate*print/pushmark*rv2av/gv
+ /leavesub/lineseq/nextstate*null/or/print/pushmark*rv2av/gv
+ /leavesub/lineseq/nextstate*null/or/print/pushmark*rv2av/gv.op_flags = 2
+ .op_private = 0
+ .op_targ = 0
+ /leavesub/lineseq/nextstate*null/or/print*die
+ .op_flags = 6
+ .op_private = 1
+ .op_targ = 2
+ /leavesub/lineseq/nextstate*null/or/print*die/pushmark
+ .op_flags = 2
+ .op_private = 0
+ .op_targ = 0
+ /leavesub/lineseq/nextstate*null/or/print*die/pushmark*rv2sv
+ .op_flags = 6
+ .op_private = 1
+ .op_targ = 15
+ /leavesub/lineseq/nextstate*null/or/print*die/pushmark*rv2sv/gvsv
+ .GV = main::!

DESCRIPTION

Runs Algorithm::Diff against two functions to make writing macros easier.

OPTIONAL EXPORTS

fmt_optree_diff( \&code_a, \&code_b, ... )

This is like optree_diff except that it returns a list of nicely formatted text descriptions of the changes to the optree.

optree_diff( \&code_a, \&code_b, ... )

A wrapped call to Algorithm::Diff::diff(). fmt_optree_diff uses this as input.

optree_sdiff( \&code_a, \&code_b, ... )

Algorithm::Diff::sdiff( ... )

optree_traverse_sequences( \&code_a, \&code_b, ... )

Algorithm::Diff::traverse_sequences( ... )

optree_traverse_balanced( \&code_a, \&code_b, ... )

Algorithm::Diff::traverse_balanced( ... )

CAVEATs

This module is still under development. While the code works mostly correctly, the test 3-and-or.t expresses a wish that redundant information not be included in the output. This module will change in small ways until I can get the output looking proper.

AUTHOR

Joshua b. Jore <jjore@cpan.org>

COPYRIGHT AND LICENSE

B::Keywords supplies seven arrays of keywords: @Scalars, @Arrays, @Hashes, @Filehandles, @Symbols, @Functions and @Barewords. The @Symbols array includes the contents of each of @Scalars, @Arrays, @Hashes and @Filehandles. Similarly, @Barewords adds a few non-function keywords (like __DATA__, NULL) to the @Functions array.

All additions and modifications are welcome.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 516:

You forgot a '=back' before '=head1'