Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.
C:\Expert-Exchange\perl>perl -F, -lane '$m{$F[0]}[1-@ARGV]=$F[1];END{print join
,",exists $m{$_}[0]&&$_,exists $m{$_}[1]&&$_,($#{$m{$_}}?"Success":"Failure"),@
$m{$_}}[0,1],$m{$_}[0]eq$m{$_}[1]?"Success":"Failure" for keys %m}' 1.txt 2.txt
Can't find string terminator "'" anywhere before EOF at -e line 1.
#!/usr/bin/perl
use strict;
use warnings;
my(@c,@m);
while( <> ){
chomp;
my @F=split/,/;
@c=@F,next unless @c;
@{$m[1-@ARGV]}{@c}=@F;
close ARGV,undef @c if 2..2;
}
$\=$/;
my @k=sort grep $m[1]{$_},keys %{$m[0]};
print join"\t",map{$_."_1",$_."_2","match"}@k;
print join"\t",map{$m[0]{$_},$m[1]{$_},$m[0]{$_}eq$m[1]{$_}?"Success":"false"}@k;
C:\Expert-Exchange\perl>perl test.pl 1.csv 2.csv
Activity Status_1 Activity Status_2 match Available Quantity_1
Available Quantity_2 match Collection Status_1 Collection Status_2
match Container name_1 Container name_2 match Created On_1
Created On_2 match Initial Quantity_1 Initial Quantity_2 match
Is Available_1 Is Available_2 match Label_1 Label_2 match Lineage_1
Lineage_2 match Pathological Status_1 Pathological Status_2 match
Position one_1 Position one_2 match Position two_1 Position two_2 match
SCG name_1 SCG name_2 match Specimen Class_1 Specimen Class_2
match Tissue Side_1 Tissue Side_2 match Tissue Site_1 Tissue S
ite_2 match Type_1 Type_2 match
Active Active Success 13.8 13.8 Success Collected Collected
Success D6 S4 R16 B5 D6 S4 R16 B5 Success 9/2/2008 9/2/2008 0:00
false 13.8 13.8 Success TRUE 1 false B0006697 B0006697
Success New New Success Not Specified Not Specified Success
6 9 false 9 6 false A RANDOMIZED PHASE II TRIAL _30
834_180328 A RANDOMIZED PHASE II TRIAL _30834_180328 Success Molecula
r Molecular Success Not Specified Not Specified Success Blood
Blood Success DNA DNA Success
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
perl -F, -lane '$m{$F[0]}[1-@ARGV]=$F[1];