in reply to Bizarre copy of ARRAY

@{@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.

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

    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

        See perlop, and likely perlretut and perlre while you're at it. "Seeing things somewhere" is a good start, but you should read up on the documentation what things mean instead of blindly using them.

        • 'x' affects how whitespace and '#' behave.
        • 'm' affects how "^" and "$" behave.
        • 's' affects how "." behaves.

        See perlre for details on the above (since they affect regex patterns) and see perlop for 'g' (since it's affects the substitution operator).