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:

# XS code SV* useofuninit(SV* arg) INIT: char *p; STRLEN plen; PPCODE: p = SvPVx(p, plen); XSRETURN_UNDEF; # Perl code my $foo; useofuninit(undef)
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
$"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc

In reply to Re: Source of warning message: "Use of uninitialized value in subroutine entry" by Stevie-O
in thread Source of warning message: "Use of uninitialized value in subroutine entry" by BrowserUk

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.