Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Source of warning message: "Use of uninitialized value in subroutine entry"by Stevie-O (Friar) |
on Dec 15, 2004 at 20:18 UTC ( [id://415183]=note: print w/replies, xml ) | Need Help?? |
The fact that you're using XS explains a lot of this.
To understand what's going on here, you need to better understand what the warning message actually means. The "Use of unitialized value" part is, as you surmised, referring to the usage of an undefined scalar as part of some operation. However, your assumption that 'in subroutine entry' means 'as part of the sub's arguments' is wrong. (If it did, then you'd get a warning every time you passed undef to a subroutine!) It actually means 'and the last Perl opcode that was run was the "entersub" opcode'. Similarly, the file/line number data you have came from the last "nextstate" opcode Perl processed. Because XS code is plain C, and not Perl bytecode, Perl can't know to update its file/line number information, or its last-opcode information. I was able to reproduce your problem doing this: SvPVx() gets the string value from a scalar. In this case, it sees that the scalar is undef, and before upgrading it to an empty string scalar, it calls report_uninit(). report_uninit() checks the last opcode data and reports the warning to you as 'in subroutine entry'.
--Stevie-O
In Section
Seekers of Perl Wisdom
|
|