Gossamer Forum
Home : General : Perl Programming :

ARRAY(0x80c6fdc)

Quote Reply
ARRAY(0x80c6fdc)
Does anyone know what this means?

ARRAY(0x80c6fdc)


He is the code causing it...

my %info = (
Name => [0, 'Paul', 'Wilson'],
);


print $info{Name};

This works $info{Name}[0]; but I thought I could use $info{Name} too?


Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: ARRAY(0x80c6fdc) In reply to
ARRAY(0x80c6fdc) is a reference to an array.

The structure you have defined is known as a "hash of arrays".

Quote Reply
Re: ARRAY(0x80c6fdc) In reply to
Thanks for the reply,

I know that.....I was wondering really why I was getting that error.

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: ARRAY(0x80c6fdc) In reply to
That is not an error. When you print a reference, you will see the reference type, hence the ARRAY, then it's hex address in memory, 0x80c6fdc.

Quote Reply
Re: ARRAY(0x80c6fdc) In reply to
Thanks...

I thought it was meant to print the values of Name.

Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: ARRAY(0x80c6fdc) In reply to
You need to dereference the value like...
Code:
@{$hash{key}}
Try this:
Code:
%test = ( foo => ["this", "that"] );
print "$_\n", foreach @{$test{foo}};
Happy Coding,

--Drew
http://www.FindingHim.com
Quote Reply
Re: ARRAY(0x80c6fdc) In reply to
Thanks Junko.


Paul Wilson.
http://www.wiredon.net/gt/
http://www.perlmad.com/
Quote Reply
Re: ARRAY(0x80c6fdc) In reply to
But I assume you can use the code " if ($info{Name})" to see if Name exists. Or not.....

my %info = (
Name => [0, 'Paul', 'Wilson'],
);


Because I'm using the followinf snippet for a time without problems:

sub build_html_record {
# --------------------------------------------------------
# Builds a record based on the config information.
#
my (%rec) = @_;
my ($output, $field);

$output = "<p><table border=1 width=675>\n";
foreach $field (@db_cols) {
next if ($db_form_len{$field} == -1);
if (($db_hyperlink_fields{$field}) && ($db_hyperlink_fields{$field}[1] eq 'popup') && ($rec{$field} !~ /^\s*$/)) {
$output .= qq~
<tr><td align=left valign=top width=30%> <$font>$field:</font></td>
<td width=70%><$font><a href="$db_hyperlink_fields{$field}[0]$rec{$field}" target="_new" onclick="top.newWin = window.open('$db_hyperlink_fields{$field}[0]$rec{$field}','PopUp','toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,width=790,height=500,top=20,left=20'); return false;">$rec{$field}</a>   </font></td></tr>
~;
} elsif (($db_hyperlink_fields{$field}) && ($rec{$field} !~ /^\s*$/)) {
$output .= qq~
<tr><td align=left valign=top width=30%> <$font>$field:</font></td>
<td width=70%><$font><a href="$db_hyperlink_fields{$field}[0]$rec{$field}" target="$db_hyperlink_fields{$field}[0]">$rec{$field}</a>   </font></td></tr>
~;
} else {
$output .= qq~
<tr><td align=left valign=top width=30%> <$font>$field:</font></td>
<td width=70%><$font>$rec{$field}   </font></td></tr>
~;
}
}
$output .= "</table></p>\n";
return $output;
}


...and in my .def file I have:

# Hash of column names to hyperlink values. If you use &build_html_record, it will
# make a <A HREF=""></A> tag for you using the url specified in the hash. You can
# use "popup" or define the target yourself.

Û_hyperlink_fields = (
'Jobengine' => ['/cgi-bin/administration/administration.cgi?db=jobs&view_records=1&ID=','popup'],
'Attachment' => ['/data/','_self'],
'Partnerwebsite' => ['http://','_new']
);