[VPM] array refs driving me nuts
Malcolm Dew-Jones
yf110 at victoria.tc.ca
Thu May 20 14:20:25 CDT 2004
On Thu, 20 May 2004, Carl B. Constantine wrote:
> WARNING WILL ROBINSON --- NEWBIE QUESTION
>
> I'm trying to print out the value of an array reference. The reference
> is passed into a function as \@array.
>
> Now in that function I pass out $arrayRef to another function. It's in
> this final function I want to print out the value(s) of the array.
>
> I've tried @$arrayRef, $$arrayRef, $@$arrayRef, @$arrayRef[0] all to no
> avail.
>
> What did I miss?
A small but complete example that illustrates the problem?
@$arrayRef would normally work.
@{$arrayRef} might be needed if it's part of something more complex.
The following example does what it sounds like you want, so whatever is
different is the problem
my @array = qw(one two three four);
sub func2 { my $arrayRef2 = shift; print "func2: @$arrayRef2 \n"; }
sub func1 { my $arrayRef1 = shift; func2($arrayRef1); }
func1( \@array );
It prints the contents of the original array.
More information about the Victoria-pm
mailing list