in reply to Extracting elements in one array but not in another

I believe that one or both of your new arrays has undefined elements in it. Your hash lookup is the correct way to do this, and the relative sizes of the arrays don't matter. Try filtering out undefined elements from arrays if they are unavoidable from the data. @array = grep { defined } @array;

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Extracting elements in one array but not in another
by jdalbec (Deacon) on Oct 23, 2004 at 15:02 UTC
    I agree that either @sorted_original_cellnames or @sorted_top_cellnames must have undefined elements in it. I tried the following code:
    #! /usr/bin/perl -w use strict; my @a = (1,2,3,4,5); my @b = (2,4,6,8); my %c; @c{@a} = undef; my @bb = grep { ! exists $c{$_} } @b; my %d; @d{@b} = undef; my @aa = grep { ! exists $d{$_} } @a; print "@aa\n"; print "@bb\n";
    and I got the following output with no warnings:
    1 3 5 6 8
    If I add an undef to @a or @b in my example, I get the warnings you describe.