in reply to Issue with multiple options for a Getopt::Long argument

\(our @option_array)
That is a reference to a COPY of @option_array.

The COPY receives the values, not the original @option_array.

(Update : See ikegami's correction below.)

Just use :

\@option_array
Here is a test case .. for some reason,the copy will not print unless it is assigned to something.
>perl -E "my @x; say qq|Orig=|,\@x; say qq|Copy:|,$_=\(@x)" Orig=ARRAY(0xdb84d8) Copy:SCALAR(0xed8c78)

                Is a computer language with goto's totally Wirth-less?

Replies are listed 'Best First'.
Re^2: Issue with multiple options for a Getopt::Long argument
by ikegami (Patriarch) on Jan 22, 2018 at 23:06 UTC

    That is a reference to a COPY of @option_array.

    No, nothing is being copied.

    In list context, \(@array) is equivalent to \($array[0], $array[1], ..., $array[-1]), which is equivalent to \$array[0], \$array[1], ..., \$array[-1].

    In scalar context, \(@array) is equivalent to \($array[0], $array[1], ..., $array[-1]), which is equivalent to \$array[-1].

    The above also applies to \(our @option_array). The OP wants \our @option_array (no parens), which returns a reference to the array.

      YES! It had to be something to do with the way I was getting the reference from the declaration. Never thought to remove the parentheses! Thanks a bunch ikegami!

      Regards, Mark.