man > B::Concise

B::Concise(3perl) Perl Programmers Reference Guide B::Concise(3perl)

📖 NAME

B::Concise - Walk Perl syntax tree, printing concise info about ops

🚀 Quick Reference

Use CaseCommandDescription
Basic rendering (default)perl -MO=Concise foo.plPrint OPs in tree order (preorder)
Execution order renderingperl -MO=Concise,-exec foo.plPrint OPs in execution order (postorder)
Tree style renderingperl -MO=Concise,-tree foo.plPrint OPs as a left-to-right tree
Include source linesperl -MO=Concise,-src foo.plPrecede each statement with its source line
Render a specific subroutineperl -MO=Concise,bar foo.plOnly render bar() from the file
Render all functions in a packageperl -MO=Concise,-stash=SomePackageRequire and render all subs in the package
Switch to terse styleset_style_standard('terse')Emulate B::Terse output
Add custom styleadd_style($name => $default, $goto, $tree)Define new rendering style
Add callback for custom variablesadd_callback(sub { my ($h, $op, ...) = @_; ... })Populate #variables for style

📋 SYNOPSIS

        perl -MO=Concise[,OPTIONS] foo.pl

        use B::Concise qw(set_style add_callback);

📝 DESCRIPTION

This compiler backend prints the internal OPs of a Perl program's syntax tree in one of several space-efficient text formats suitable for debugging the inner workings of perl or other compiler backends. It can print OPs in the order they appear in the OP tree, in the order they will execute, or in a text approximation to their tree structure, and the format of the information displayed is customizable. Its function is similar to that of perl's -Dx debugging flag or the B::Terse module, but it is more sophisticated and flexible.

💡 EXAMPLE

Here's two outputs (or 'renderings'), using the -exec and -basic (i.e. default) formatting conventions on the same code snippet.

    % perl -MO=Concise,-exec -e '$a = $b + 42'
    1  <0> enter
    2  <;> nextstate(main 1 -e:1) v
    3  <#> gvsv[*b] s
    4  <$> const[IV 42] s
*   5  <2> add[t3] sK/2
    6  <#> gvsv[*a] s
    7  <2> sassign vKS/2
    8  <@> leave[1 ref] vKP/REFC

In this -exec rendering, each opcode is executed in the order shown. The add opcode, marked with '*', is discussed in more detail.

    % perl -MO=Concise -e '$a = $b + 42'
    8  <@> leave[1 ref] vKP/REFC ->(end)
    1     <0> enter ->2
    2     <;> nextstate(main 1 -e:1) v ->3
    7     <2> sassign vKS/2 ->8
*   5        <2> add[t1] sK/2 ->6
    -           <1> ex-rv2sv sK/1 ->4
    3              <$> gvsv(*b) s ->4
    4           <$> const(IV 42) s ->5
    -        <1> ex-rv2sv sKRM*/1 ->7
    6           <$> gvsv(*a) s ->7

The default rendering is top-down, so they're not in execution order. This form reflects the way the stack is used to parse and evaluate expressions; the add operates on the two terms below it in the tree.

⚙️ OPTIONS

Arguments that don't start with a hyphen are taken to be the names of subroutines or formats to render; if no such functions are specified, the main body of the program (outside any subroutines, and not including use'd or require'd files) is rendered. Passing "BEGIN", "UNITCHECK", "CHECK", "INIT", or "END" will cause all of the corresponding special blocks to be printed. Arguments must follow options.

Options affect how things are rendered (ie printed). They're presented here by their visual effect, 1st being strongest. They're grouped according to how they interrelate; within each group the options are mutually exclusive (unless otherwise stated).

🔹 Options for Opcode Ordering

🎨 Options for Line-Style

🌳 Options for tree-specific formatting

🔢 Options controlling sequence numbering

📋 Other options

🔒 Option Stickiness

Options are sticky across multiple invocations; change them by re-specifying.

📚 ABBREVIATIONS

🔤 OP class abbreviations

🚩 OP flags abbreviations

Private flags (after '/') are opcode-specific; see B::Op_private.

📐 FORMATTING SPECIFICATIONS

For each line-style, there are 3 format-specs: default (basic/exec), goto (exec mode), tree.

🔣 Special Patterns

🏷️ Variables (#vars)

The following variables are available for use in style definitions:

💻 One-Liner Command tips

🔧 Using B::Concise outside of the O framework

The common usage is command-line, but you can call compile() directly and repeatedly.

🛠️ Example: Altering Concise Renderings

    use B::Concise qw(set_style add_callback);
    add_style($yourStyleName => $defaultfmt, $gotofmt, $treefmt);
    add_callback
      ( sub {
            my ($h, $op, $format, $level, $stylename) = @_;
            $h->{variable} = some_func($op);
        });
    $walker = B::Concise::compile(@options,@subnames,@subrefs);
    $walker->();

📝 set_style()

Accepts 3 arguments (basic-exec, goto, tree). Prefer add_style() or set_style_standard().

🔄 set_style_standard($name)

Restores a predefined style: "terse", "concise", "linenoise", "debug", "env", or custom.

➕ add_style()

Registers a new style name with three format strings.

🔗 add_callback()

Registers a callback to populate #variables. Called for each op with parameters: hashref, op object, format ref, indent level, style name.

🏃 Running B::Concise::compile()

Returns a coderef that walks and renders the optrees. You can change style between calls. walk_output changes print destination.

  my $walker = B::Concise::compile('-terse','aFuncName', \&aSubRef);
  walk_output(\my $buf);
  $walker->();
  set_style_standard('concise');
  $walker->();

🔄 reset_sequence()

Resets sequence numbers for testing (not exported).

⚠️ Errors

Rendering errors are written to STDOUT or walk_output destination. Style and argument errors die().

👤 AUTHOR

Stephen McCamant, <smcc AT CSUA.EDU>.

perl v5.34.0 2026-06-23 B::Concise(3perl)

B::Concise
📖 NAME 🚀 Quick Reference 📋 SYNOPSIS 📝 DESCRIPTION 💡 EXAMPLE ⚙️ OPTIONS
🔹 Options for Opcode Ordering 🎨 Options for Line-Style 🌳 Options for tree-specific formatting 🔢 Options controlling sequence numbering 📋 Other options 🔒 Option Stickiness
📚 ABBREVIATIONS
🔤 OP class abbreviations 🚩 OP flags abbreviations
📐 FORMATTING SPECIFICATIONS
🔣 Special Patterns 🏷️ Variables (#vars)
💻 One-Liner Command tips 🔧 Using B::Concise outside of the O framework
🛠️ Example: Altering Concise Renderings 📝 set_style() 🔄 set_style_standard($name) ➕ add_style() 🔗 add_callback() 🏃 Running B::Concise::compile() 🔄 reset_sequence() ⚠️ Errors
👤 AUTHOR

Generated by phpman v4.9.25-8-g32d6339 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-12 03:22 @216.73.217.22
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-pro / taotoken.net / www.chedong.com - original format

^_top_^