august3 has asked for the wisdom of the Perl Monks concerning the following question:
To find the elements that are not found in the first array I wrote1. @sorted_original_cellnames 2. @sorted_top_cellnames
Similarly for the second array I wrote@test1{@sorted_original_cellnames} = undef; @not_found_in_original = grep{!exists $test1{$_}}@sorted_top +_cellnames;
This code was working fine as long as we had the same number of elements in both the arrays. Today I have a new situation -> I have 71 items in the first array and only 66 items in the second. The code is not working properly. It generates @not_found_in_originalarray with 5 elements of nothing and the @not_found_in_topcell with 5 elements that are missing. Also the code gives following errors@test2{@sorted_top_cellnames} = undef; @not_found_in_topcell = grep{!exists $test2{$_}}@sorted_orig +inal_cellnames;
I tried rewriting the code with foreach, still I get the same problem, any idea to correct this. Thanks in adavance for all who helps me. AugustineUse of uninitialized value in exists at checkmodlist.pl line 355. Use of uninitialized value in hash slice at checkmodlist.pl line 358.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Extracting elements in one array but not in another
by neilh (Pilgrim) on Oct 23, 2004 at 03:49 UTC | |
Re: Extracting elements in one array but not in another
by Zaxo (Archbishop) on Oct 23, 2004 at 03:55 UTC | |
by jdalbec (Deacon) on Oct 23, 2004 at 15:02 UTC | |
Re: Extracting elements in one array but not in another
by emazep (Priest) on Oct 23, 2004 at 06:50 UTC | |
Re: Extracting elements in one array but not in another
by DrHyde (Prior) on Oct 25, 2004 at 09:12 UTC | |
Re: Extracting elements in one array but not in another
by TomDLux (Vicar) on Oct 25, 2004 at 14:23 UTC |