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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: On the dangers of too much debugging text
by perrin (Chancellor) on Mar 28, 2008 at 14:40 UTC | |
|
Re: On the dangers of too much debugging text
by dragonchild (Archbishop) on Mar 28, 2008 at 16:54 UTC | |
|
Re: On the dangers of too much debugging text
by zby (Vicar) on Mar 28, 2008 at 14:17 UTC | |
|
Re: On the dangers of too much debugging text
by oko1 (Deacon) on Mar 28, 2008 at 19:51 UTC | |
|
Re: On the dangers of too much debugging text
by kyle (Abbot) on Mar 28, 2008 at 16:27 UTC |