Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am getting the following error when debugging my script using perl -d:ptkdb.What is wrong with my push?

Bizarre copy of ARRAY in leave at E:\1013\CS_includes.pl line 20 Line 20 is push @header_present,grep( (/\Q$header_file\E/xmsgi), @{@headers });

Replies are listed 'Best First'.
Re: Bizarre copy of ARRAY
by ikegami (Patriarch) on Mar 20, 2011 at 07:20 UTC

    It means an AV (array) got put on the stack by some buggy XS code.

    use Inline C => <<'__EOI__'; SV* f() { return (SV*)newAV(); } __EOI__ my $x = f(); # Bizarre copy of ARRAY in sassign.

      As it applies in this case, I suspect your version of Perl has a bug in its handling of @{@headers}, which is also buggy. Did you mean @headers? @{$headers}? @{@headers} definitely ain't right.

Re: Bizarre copy of ARRAY
by BrowserUk (Patriarch) on Mar 20, 2011 at 07:22 UTC

    Why are wrapping an array @headers in an array dereference @{ ... }?

    It is already an array, so you don't need to dereference it to get at an array.


    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.
Re: Bizarre copy of ARRAY
by GrandFather (Saint) on Mar 20, 2011 at 07:26 UTC

    I can't reproduce the error you are seeing, but if you use strictures (use strict; use warnings; ) I'd expect @{@headers} to generate:

    Can't use string ("n") as an ARRAY ref while "strict refs" in use at . +..

    where n is the number of elements in @headers. Quite likely this is related to your problem. What were you wanting to achieve with @{@headers}?

    True laziness is hard work
Re: Bizarre copy of ARRAY
by jwkrahn (Abbot) on Mar 20, 2011 at 07:26 UTC

    @{@headers } should be @{$headers }, or just @$headers.

    Why are you using the options xmsgi on your regular expression?    The x, m, s and g options are superfluous.

      The 'g' is not superfluous; it's wrong (i.e. buggy, can cause errors). 'g' in scalar context is almost always wrong.

        BTW,what are x,m,g,s for?I am using it because I saw it somewhere and thought its useful