in reply to Re: Problem to inspect scalars in STASH
in thread Problem to inspect scalars in STASH

Thanks for your help... :)

> The solution I came up with is to use defined($$name) for scalars,

Sorry, that's not a solution because it excludes all declared package variables which became undef in the meantime.

Think of something like  $flag = () in the middle of the code. I'm trying to fix the tab-expansion in the perldebugger, actually $f#TAB# lists all symbols starting with f, no matter which slot is used.

DB<223> sub flo {} => 0 DB<224> $f # type TAB $f $find $flag $flo

As a workaround I could include all symbols where only the scalar slot is defined, but if someone decides to have equally named sub &flo AND scalar $flo where the latter is undef, I can't tell if the scalar belongs to the code or not.

While this cases seems rare enough - most people tend to use different names for different sigils - it's not a 100% solution.

If there is no better suggestion, I will need to parse the code to reliably find all scalars.

>Yes, this is annoying,

FWIW I consider this behavior a bug.

Cheers Rolf

Replies are listed 'Best First'.
Re^3: Problem to inspect scalars in STASH
by educated_foo (Vicar) on Feb 16, 2012 at 02:31 UTC
    You're right, of course, and I agree that the SCALAR auto-vivification thing is a bug. I remember discussing this with some P5P folks awhile back, and IIRC this auto-creation of the SCALAR slot was fairly well-baked into the core. Still, you think that wandering through the symbol table should be easy -- it's just a hash of GLOBs, right? -- and then you run into all this stuff. *sigh*