in reply to Re: comparing two arrays
in thread comparing two arrays

Consider:

file1 6.66 6.75 6.75 6.66 6.75 6.75 7.17 7.17 7.31 7.31 7.41 7.41 file2 6.75 6.66 6.75 6.75 7.17 7.17 7.31 7.31 7.41 7.41 6.62 6.75

which should generate:

6.62 6.66

Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^3: comparing two arrays
by borisz (Canon) on Oct 20, 2005 at 18:50 UTC
    Upps, you are so right.
    use Fatal qw/open/; my ( %h, %g ); open my $fh, '<', '/tmp/file1'; while ( defined ($_ = <$fh>)){ /^([\d\.]+)/ and $h{$1}++; } open $fh, '<', '/tmp/file2'; while ( defined ($_ = <$fh>)){ /^([\d\.]+)/ and $g{$1}++; } my @k = keys %h; delete @h{keys %g}; delete @g{@k}; print join "\n",( keys %h, keys %g );
    Boris