Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Why does it tell me that $lex is a reference to undef?
    $ ./padtest.pl
    $VAR1 = {
              '$lex' => \undef,
              '$l' => \0
            };
    While you're here, I'll print my enclosed scalar: HELLO
    Had to add the shebang... but that was the only change I made.

    This is on Debian with Perl 5.8.4
  • use Data::Dumper;
    use PadWalker qw(peek_my);
    {
      my $lex = "HELLO";
      sub pad {
        my $l = shift;
        warn Dumper(peek_my($l));
        print "While you're here, I'll print my enclosed scalar: $lex\n";
      }
    }
    pad(0);

    t sure what your expecting to see
    Based on Persistent Private Variables in perlsub it sounds like the problem is the pad sub is getting created at compile time and my is happening at runtime and this leads to the sub picking up a reference to $lex too early. This