Skip to content

Instantly share code, notes, and snippets.

@davorg
Created June 28, 2013 10:38
Show Gist options
  • Save davorg/5883837 to your computer and use it in GitHub Desktop.
Save davorg/5883837 to your computer and use it in GitHub Desktop.
Add an MD5 hash to lines of data that have already been seen.
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Digest::MD5 'md5_hex';
my %seen;
while (<DATA>) {
chomp;
$_ .= ' ' . md5_hex($_) if $seen{$_}++;
say $_;
}
__DATA__
NAME AGE GENDER DEP-Id Company
AA 30 M IT-001 google.com
AA 30 M IT-001 google.com
AB 40 F IT-002 Yahoo.com
AB 40 F IT-002 Yahoo.com
AC 50 F IT-004 ABC.com
AC 50 F IT-004 ABC.com
AA 30 M IT-001 google.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment