How to check if there is an existing entry in array of the hash in perl..please, please

Discussion in 'Perl Misc' started by Cyrus, Dec 20, 2006.

  1. Cyrus

    Cyrus Guest

    Hi folks,
    I'm new in this group, I would like to ask all of the Perl experts out
    there, if any one knows how to prevent a duplicated entry in array of
    the hash: here is what I need to do. The script periodically check for
    disk status if there is an error it adds it to array of the hash with
    keys & value, what I need is before it push/append it to the array of
    the hash it check to see if the key & value exists if not then
    push/append it else do other stuff or next
    Thanks in advance & hop I can get an answer from one of you guys..
    Cheers

    Here is a portion of the code:
    my $sh = $c->show_disk();
    foreach my $sys (@sys_arry) {
    foreach my $el (@$sh) {
    if ($el->{'status'} ne "OK")
    {
    # Here I know I should check to see if the keys & value exits
    but don't know how!!
    push @DiskErr, {sys=>$sys, disk=>$el->{'id'},
    status=>$el->{'status'}};
    } else
    {
    print "$sys: Status OK\n";
    }
    }
    }
     
    Cyrus, Dec 20, 2006
    #1
    1. Advertising

  2. Cyrus

    Cyrus Guest

    Mirco Wahab wrote:
    > Thus spoke Cyrus (on 2006-12-20 20:37):
    >
    > > # Here I know I should check to see if the keys & value exits
    > > # but don't know how!!
    > > push @DiskErr, {
    > > sys => $sys,
    > > disk => $el->{'id'},
    > > status => $el->{'status'}
    > > };

    >
    > Which "key and value". There are *three* of
    > them each. Do they depend on each other?
    > Or are they orthogonal?
    >
    > Regards
    >
    > Mirco
     
    Cyrus, Dec 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rp
    Replies:
    1
    Views:
    537
    red floyd
    Nov 10, 2011
  2. Srijayanth Sridhar
    Replies:
    19
    Views:
    625
    David A. Black
    Jul 2, 2008
  3. Siratinee Sukachai
    Replies:
    1
    Views:
    141
    7stud --
    Apr 22, 2011
  4. Cyrus
    Replies:
    1
    Views:
    79
    A. Sinan Unur
    Dec 20, 2006
  5. Replies:
    14
    Views:
    187
    C.DeRykus
    Dec 22, 2009
Loading...

Share This Page