Thanks for all the responses. I appreciate the time you all took to provide an answer and the answers all pretty much confirm what I thought I already knew.

Here's an excerpt from the documentation on the CGI::param method: "...param returns a list of all of the values if it is called in a list context and just the first value if it is called in a scalar context.". So I wanted to avoid copying the contents of $q->param('at0') to another location and then passing a reference to that new array. I just wanted to pass a reference to the existing array. Hence my desire to use option 2) instead of 1). But using option 2) returns the following runtime error: "Can't use string ("H&C05.01") as an ARRAY ref...". Just to clear up the nature of the beast a few prints may be useful:

print Dumper($q->param('at0'))."\n"; # generates: $VAR1 = 'H&C05.01'; $VAR2 = 'SETT04.03';

print Dumper([$q->param('at0')])."\n"; # generates: $VAR1 = [ 'H&C05.01', 'SETT04.03' ];

print \@{$q->param('at0')}."\n"; # generates: Can't use string ("H&C05.01") as an ARRAY ref while "strict refs" in u +se at ...

So I'm probably being really dense here, but I still don't understand why I can't just generate a reference to the existing array instead of copying the contents of the array to another location and generating a reference to that new location. Is it because I'm working with a method instead of a property of the CGI object?

Still in the fog.


In reply to Re: Array Reference by rhumbliner
in thread Array Reference by rhumbliner

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.