I'm using Catalyst to build an application, and are using the Catalyst::Controller::BindLex module to keep the code more readeable:

my $value :Stashed = 1;

in stead of

$c->stash( value => 1 );

This is all great stuff until you have:

sub action : Chained('other_action') { my $value: Stashed; # # a bit of code using $value # my $value: Stashed = 1; }

The last line was there in the initial iteration of the action, the first line got added after some redesign.

Catalyst server started up as usual with a summary of actions, paths, plugins, and a lot of my own debug prints. The first notice something was wrong was when I got:

panic: Can't find SCALAR(0x3240d90) in the the caller's lexical pa +d

This sent me on a merry chase through all the internals using the debugger. Somehow BindLex saw a different address for $value than the one I saw in the debugger. After a couple of hours, lots of coffee, and some silly experiments I decided to take a shower and go to bed. It was after 5AM after all....

Somewhere between shower and bed it dawned on me. The reason BindLex was seeing a different address must be because there were 2 vars with the same name in the subroutine's scope!! So I went back and looked closely at the output of the server start again, and there it was, as the first line of output:

"my" variable $value masks earlier declaration in same scope.

So, lessons learned:

--
Lyon


In reply to On the dangers of too much debugging text by redlemon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.