in reply to Array Reference
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array Reference
by BrowserUk (Patriarch) on Feb 11, 2005 at 05:17 UTC | |
by rhumbliner (Sexton) on Feb 11, 2005 at 15:39 UTC |