Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array ref isn't an aray ref when dereferencing?

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hi,

I have an Object variable referencing an array
Code:
    $self->{SUBS} = \@top10;

if I then print the value with
Code:
print $self->{SUBS};
i get
ARRAY(0x2b0e53c)
which tells me it is an array reference.

However if I then try to dereference the array with
Code:
print "Array Count = " . @$self->{SUBS};
I get
Not an ARRAY reference

I'm confused! What am I doing wrong?

Cheers,
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
OK, worked it out.

I needed the extra curly brace dereferencing syntax
Code:
print "Array Count = " . @[COLOR=red]{[/color]$self->{SUBS}[COLOR=red]}[/color];





"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top