I replaced the old mod:
for my $i (0 .. $numlinks - 1) {
$tmp = $LINKDB->array_to_hash (${$links_r}[$i]);
if ($tmp->{Priority} > 0) {
$OUT{featured} .= &site_html_link ($tmp);
}
}
with your code above, i.e.
for my $i (0 .. $numlinks - 1) {
$tmp = $LINKDB->array_to_hash (${$links_r}[$i]);
## $tmp is now a pointer to a hash of the Link values _NOT_ an array pointer!
## delete()ing tmp would do nothing to the original array elements.
if ($tmp->{Priority} > 0) {
$OUT{featured} .= &site_html_link ($tmp);
splice (@$links_r, $i, 1); ## need to dereference the array
$numlinks=$numlinks-1; ## need to reset the size of the array
$i=$i-1; ## need to re-check the new element $1
}
}
But I get this error when I build:
DBSQL (9687): Fatal Error: Invalid argument type '' passed to array_to_hash at nph-build.cgi line 461
Did I need to add any other code around the new code or what have I done wrong?
JeffB
for my $i (0 .. $numlinks - 1) {
$tmp = $LINKDB->array_to_hash (${$links_r}[$i]);
if ($tmp->{Priority} > 0) {
$OUT{featured} .= &site_html_link ($tmp);
}
}
with your code above, i.e.
for my $i (0 .. $numlinks - 1) {
$tmp = $LINKDB->array_to_hash (${$links_r}[$i]);
## $tmp is now a pointer to a hash of the Link values _NOT_ an array pointer!
## delete()ing tmp would do nothing to the original array elements.
if ($tmp->{Priority} > 0) {
$OUT{featured} .= &site_html_link ($tmp);
splice (@$links_r, $i, 1); ## need to dereference the array
$numlinks=$numlinks-1; ## need to reset the size of the array
$i=$i-1; ## need to re-check the new element $1
}
}
But I get this error when I build:
DBSQL (9687): Fatal Error: Invalid argument type '' passed to array_to_hash at nph-build.cgi line 461
Did I need to add any other code around the new code or what have I done wrong?
JeffB