in reply to referencing hell

Your question isn't very clear, but I think you might mean something like this:

my @wanted = grep { $_->{ID} == $id } @array;
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me

Replies are listed 'Best First'.
Re: Re: referencing hell
by purge (Acolyte) on May 03, 2001 at 18:59 UTC
    Thanks for all the swift replies, I think I understand how you have done it, it certainly works, though a quick explanation wouldn't go amiss.
    I will make myself more clear next time, but I wasn't quite sure what I wanted either at the time :)

    Thanks again
    Purge.
      a quick explanation wouldn't go amiss...

      Here's an explanation of what davorg suggested...

      First, let's look at your data. The line 'push @array, \%data;' in your code builds an array of references to hashes. You might picture the contents of @array as looking a little like this: (hashref1, hashref2, hashref3, hashref4, etc.) So... davorg's line of code (reading it right to left) says:

        for each value in @array...
          (and we know those values are hash references)
        dereference each hashref...
          (using the $hashref->{key} syntax)
        to give us the value associated with the ID key.
        If that value taken as a number...
          (otherwise you would want to use 'eq' instead of '==')
        equals the value of $id...
        'pass it through' to be included in @wanted.

      HTH