see Update

Ok I've had another go. This time within the debugger and the output is leaning more towards concise. However, I am now unsure whether I have something that could relate to the issue or if it's because am still noobing DB.

Apart from getting contexts out of kilter, there are a couple of issues. Firstly,( moved to new SoPW Should high traceDepth trace into debugger code? )

Secondly, I get a 'panic' warning, about attempting to copy a freed scalar. So I'm in panic mode and posting this now, along with the trace I attempted. Its probably nothing right?

DB<57> x sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ +shift @d }; ${ wants( @a ) } 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( @a ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( @a ) }; in $=main::wants() from (eval 50)[C:/Dwimperl/perl/lib/perl5db.pl:640 +]:2 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( @a ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( @a ) }; 0 undef DB<58> x sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ sh +ift @d }; ${ wants( undef @b ) } 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( undef @b ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( undef @b ) }; in $=main::wants(undef) from (eval 51)[C:/Dwimperl/perl/lib/perl5db.p +l:640]:2 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( undef @b ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; ${ wants( undef @b ) }; 0 undef DB<59> x sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ sh +ift @d }; @{ wants( @c , undef @c ) } 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; @{ wants( @c , undef @c ) }; 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; @{ wants( @c , undef @c ) }; in $=main::wants('', 1, undef, 2, undef) from (eval 52)[C:/Dwimperl/p +erl/lib/perl5db.pl:640]:2 2: sub wants{ @d = @_; wantarray ? ( shift @d, shift @d ) : \ s +hift @d }; @{ wants( @c , undef @c ) }; panic: attempt to copy freed scalar 302528c to 30257dc at (eval 52)[C: +/Dwimperl/perl/lib/perl5db.pl:640] line 2.

Update Ok scratch that, I added use strict; Also, moved the 'Firstly' out to a new SoPW.

DB<69> x use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( s +hift @d, shift @d ) : shift @d }; wants( @a ) in $=CODE(0x3025d1c)() from (eval 62)[C:/Dwimperl/perl/lib/perl5db.pl +:640]:2 in $=strict::import('strict') from (eval 62)[C:/Dwimperl/perl/lib/pe +rl5db.pl:640]:2 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); in @=main::wants() from (eval 62)[C:/Dwimperl/perl/lib/perl5db.pl:640 +]:2 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); 2: use strict; my @d; my @a; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @a ); 0 undef 1 undef DB<70> x use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( s +hift @d, shift @d ) : shift @d }; wants( undef @b ) in $=CODE(0x3025f1c)() from (eval 63)[C:/Dwimperl/perl/lib/perl5db.pl +:640]:2 in $=strict::import('strict') from (eval 63)[C:/Dwimperl/perl/lib/pe +rl5db.pl:640]:2 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); in @=main::wants(undef) from (eval 63)[C:/Dwimperl/perl/lib/perl5db.p +l:640]:2 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); 2: use strict; my @d; my @b; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( undef @b ); 0 undef 1 undef DB<71> x use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( s +hift @d, shift @d ) : shift @d }; wants( @c, undef @c ) in $=CODE(0x30280a4)() from (eval 64)[C:/Dwimperl/perl/lib/perl5db.pl +:640]:2 in $=strict::import('strict') from (eval 64)[C:/Dwimperl/perl/lib/pe +rl5db.pl:640]:2 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); in @=main::wants(undef) from (eval 64)[C:/Dwimperl/perl/lib/perl5db.p +l:640]:2 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); 2: use strict; my @d; my @c; sub wants{ @d = @_; wantarray ? ( +shift @d, shift @d ) : shift @d }; wants( @c, undef @c ); 0 undef 1 undef DB<72>

After attempting to do as you suggested, and reading plenty (read not nearly enough) of documentation, I have a little more appreciation for the debugger and how it can be used. If not actually managing to get any closer to the OP.

As for using wantarray to view the contexts, for a moment there I thought there was a void built-in.

But I see now that they are word-strings being returned to represent contexts.

documentation visited


In reply to Re^8: shift on empty array in list context broken (show context) by Don Coyote
in thread shift on empty array in list context broken by LanX

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.