Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: comparing two sets of data

by marquezc329 (Scribe)
on Nov 28, 2012 at 08:12 UTC ( #1005976=note: print w/ replies, xml ) Need Help??


in reply to comparing two sets of data

Hello mimiandi,

While I agree that your OP needs clarification and supplemental code, here is a simple method using grep to gather keys that differ.

#!/usr/bin/perl use strict; use warnings; my %file1 = ( samp1 => 'stuff', samp2 => 'data', samp3 => 'info', samp4 => 'foo', samp5 => 'bar', blah => 'blah', brood => 'other' ); my %file2 = ( samp1 => 'stuff', samp2 => 'diff', samp3 => 'blah', samp4 => 'foo', junk => 'stuff', trash => 'other', samp5 => 'bar' ); my (@diff1, @diff2); push @diff1, grep !$file2{$_}, keys %file1; push @diff2, grep !$file1{$_}, keys %file2;

Depending on the complexity of your data, you may want to have a look at Data::Compare. I believe Test::More also offers some tools for comparing data structures.

Post some code or at least some sample input data and I'm sure you'll rope some better answers.

Suggested Reading: How (Not) To Ask A Question


Comment on Re: comparing two sets of data
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2014-07-22 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (127 votes), past polls