Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat does "CODE(0x1431a90)" mean when the Perl debugger outputs this for $DB::sub?
    text
    copied!<p>I have a question about the output that I'm getting from a simple custom Perl debugger.</p> <p>If I have a simple Perl debugger like this example:</p> <pre><code>package DB { sub DB {} sub sub { my ($package, $filename, $line_num, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash) = caller(0); print "$package $DB::sub\n"; &amp;$DB::sub; } } 1; </code></pre> <p>And I run it on a simple program like the following (invoked via <code>perl -d test.pl</code>):</p> <pre><code>#!/usr/bin/env perl use strict; use warnings; sub hello { print "hello world\n"; } &amp;hello; </code></pre> <p>And the output is along the lines of the following:</p> <pre><code>main CODE(0x1431a90) main strict::import main strict::bits main CODE(0x1431be0) main warnings::import main::hello hello world </code></pre> <p>My question is:</p> <p>What does the "CODE(0x1431a90)" part represent? It seems to represent the main body of the program - since there is no subroutine at the topmost level, this seems to be a memory reference to the main execution of the program.</p> <p>What assumptions can I make about what "CODE(...)" means when I see it being printed out by my debugger? Is it always this "main" code path? Are there any other special Perl variables that I can use to interpret where the program is at that point?</p> <p>Thanks!</p> <hr> <p>EDIT - revised example 1:</p> <p>In reference to the discussion in the comments, adding additional example:</p> <pre><code>#!/usr/bin/env perl use strict; use warnings; sub hello { print "hello world\n"; } &amp;hello; print "hi from main\n"; </code></pre> <p>And output:</p> <pre><code>main CODE(0x22f0a90) main strict::import main strict::bits main CODE(0x22f0be0) main warnings::import main::hello hello world hi from main </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload