in reply to Re: Is the documentation for Perl 5.20 'pack' correct?
in thread Is the documentation for Perl 5.20 'pack' correct?

(Aside: If anyone groks why I get the uninitialized value in subroutine entry warning; please enlighten me?)

Can't say that I actually grok it, but if you remove the sv_catpvf() call it goes away.

Cheers,
Rob
  • Comment on Re^2: Is the documentation for Perl 5.20 'pack' correct?

Replies are listed 'Best First'.
Re^3: Is the documentation for Perl 5.20 'pack' correct?
by BrowserUk (Patriarch) on Jul 07, 2015 at 07:20 UTC

    Okay. I found a way to make it go away. Initialising out silences the warning:

    #! perl -slw use strict; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'END_C', NAME => 'Endian', CLEAN_AFTER_BUILD =>0; SV *hexDump( UV in ) { int i; char *p = (char*)&in; SV *out = newSVpvn( "?", 1 ); for( i=0; i<8; ++i ) { sv_catpvf( out, "%02x", p[i] ); } return out; } END_C print hexDump( 72623859790382856 ); __END__ C:\test>endian ?0807060504030201

    Which I guess means that the doc for newSVpvn() that reads:"If the s argument is NULL the new SV will be undefined. means something different to what I took it to mean.

    This also works:

    SV *hexDump( UV in ) { int i; char *p = (char*)&in; SV *out = newSVpvn( "", 0 ); for( i=0; i<8; ++i ) { sv_catpvf( out, "%02x", p[i] ); } return out; }

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
    I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!