Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to check if there is an existing entry in array of the hash in perl..please, please

Reply
Thread Tools

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

 
 
Cyrus
Guest
Posts: n/a
 
      12-20-2006

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";
}
}
}

 
Reply With Quote
 
 
 
 
Cyrus
Guest
Posts: n/a
 
      12-20-2006

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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
hash of hash of hash of hash in c++ rp C++ 1 11-10-2011 04:45 PM
Can I check the a hash contain another hash in deep check? Siratinee Sukachai Ruby 1 04-22-2011 07:43 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
Part 2: How to prevent duplicated entry in array of the hash ...please Cyrus Perl Misc 1 12-20-2006 11:45 PM



Advertisments