On Nov 5, 7:07 am, [EMAIL PROTECTED] (Rob Wilkerson) wrote:
> I'm working on a script that retrieves data from a database into a
> hashref (using fetchall_hashref) and returns the hashref to the body
> of the script before being used in a later subroutine.  What seems to
> be happening, though, is that the entire hashref is never being
> returned.  I get the primary hashref with all of the record
> identifiers, but none of the fields exist.  I *think* I've got the
> syntax right

I didn't (have the syntax right).  I'm still figuring out how to use
references properly and the required notation so I've tracked down at
least part of the problem.  I'm still having some issues, though,
accessing specific hash members, though.  I have a get_elements()
subroutine that returns the hashref that is populated as:

hashref[element_id 1][type_id]
                               [resolution_type_id]
                               [root_type_id]

The hashref contains ~8500 element_id keys.  From another source, I
get a set of element ids that I'm looping over and I need to:

1.  Ensure that the element ID exists in the hashref
2.  Extract the rest of the data (root type, resolution type, etc.)
from the hashref

I can't find a way to reference a specific element ID member that
works.  I'm parsing an element list (of arbitrary length) that looks
like this: 1=9|2=16|3=24|4=18|5=200103|7=200016|8=200076|142=300221|
152=300252|205=29941|206=37030|207=29947|208=30023|

The syntax is element_type_id_1=element_id_1|
element_type_id_2=element_id_2|...|element_type_n=element_id_n|

my %elements = split ( /[=|]/, $elementlist );
foreach my $elementtype ( keys %elements ) {
        my $elementid       = $elements{$elementtype};
        my $elementtypeid = ${$eleref->{$elementid}}{'elem_typ_id'};
        my $roottypeid       = ${$eleref->{$elementid}}{'root_elem_typ_id'};
        my $restypeid        = ${$eleref->{$elementid}}
{'resoln_elem_typ_id'};

        /snip/
}

I've tried many, many syntax variations, but can't seem to find one
that works.  At this point, I'm pretty confident that it's a syntax
issue, but I'm at a loss.  Any help dereferencing properly would be a
huge help.

Thanks again.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to