Re: How to take a reference "in line"

2006-01-19 Thread RangerRickCA
 
Please remove me from this list!  Thank you!
 
RRCA



Re: How to take a reference "in line"

2006-01-18 Thread Todd W

"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.



> 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]
 




Re: How to take a reference "in line"

2006-01-16 Thread Shawn Corey

Bill Gradwohl wrote:

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?


Try:
  check_required_items("Mr. Howell", $arrayPointer=[qw(Money preserver 
sunscreen)] );

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


--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]