in reply to Re: Why "Bizzare copy" ?
in thread Why "Bizzare copy" ?

In that case
$#{@1}

would die in the same way. It does not.

Replies are listed 'Best First'.
Re*3: Why "Bizzare copy" ?
by Tomte (Priest) on Mar 30, 2004 at 10:34 UTC

    $#{@1}
    would die in the same way. It does not.

    No, it wouldn't, as it doesn't use a symbolic reference...

    If you take the time to dump or peek at @1, you'll see that it exists as empty array...as do all @NUM I tested.

    My guess was, that @1 exists as a side effect of $1 beeing a default-variable and the "multi-type" nature of perl variables. I'd love to be corrected/educated on this rather blunt assumption I wasn't able to backup with my first dive into Devel::Peek and the like.

    regards,
    tomte


    Hlade's Law:

    If you have a difficult task, give it to a lazy person --
    they will find an easier way to do it.

Re: Re: Re: Why "Bizzare copy" ?
by bunnyman (Hermit) on Mar 30, 2004 at 21:33 UTC

    Actually, it does die, but only in the debugger.

    % perl -d -e '$#{@1}' Default die handler restored. Loading DB routines from perl5db.pl version 1.07 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): $#{@1} DB<1> c Bizarre copy of ARRAY in leave at -e line 1. Debugged program terminated.

    Without the debugger, it works fine.

    This error message is created in sv.c, in the function Perl_sv_setsv. This function copies a scalar value from one location to another. "Bizarre copy of ARRAY in leave" means that an opcode called "leave" tried to copy an array to a scalar, should be impossible. "leave" is the opcode for leaving a block of code. Why this happened, I cannot figure out.

Re: Re: Re: Why "Bizzare copy" ?
by Anonymous Monk on Mar 30, 2004 at 11:04 UTC
    correction: in that case
    $#{@{"1"}}
    would die in the same way. This however, does work:
    @a=@{//};$#a
    Why?
      $#{@{1}}, $#{@{'1'}} and $#{@{"1"}} all die in the same way.

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law