"Bill Gradwohl" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Using the example below (partially taken from Learning PERL Objects), I
> can't seem to figure out how to take a reference to an array in-line.

<snip />

> my $arrayPointer;
>
> # This works:
> @{$arrayPointer}=qw(Money preserver sunscreen);
> check_required_items("Mr. Howell", $arrayPointer);
>
> # These don't work:
> check_required_items("Mr. Howell", @{$arrayPointer}=qw(Money preserver
sunscreen));
> check_required_items("Mr. Howell", qw(Money preserver sunscreen));
>
>
> How do I tell Perl to give me a reference to an array in the last 2
> statements? There's got to be a way to pass a reference without having
> to explicitly name a variable. Right?
>

You bet:

check_required_items("Mr. Howell", [qw(Money preserver sunscreen)] );

a generic construct looks like this:

my $array_ref = [ 'foo', 'bar', 'bazz' ];

perldoc perlref

Todd W.




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to