2015_newbie has asked for the wisdom of the Perl Monks concerning the following question:
first.txt /vol/cat,feline /vol/dog,canine /vol/cat,feline /vol/cat,feline /vol/amphibian,FROG /vol/amphibian,FROG
second.txt 9,/vol/elephant,fourfeet 1999,/vol/dolphin,fish 10,/vol/cat,feline 1111,/vol/goldfish,fish 2222,/vol/spider,arachnid 5555,/vol/camel,dromedary <code> #!/usr/bin/perl use strict; use warnings; sub get_file { open my $FILE, '<', shift or die $!; return map {$_ => $_} <$FILE>; return map {$_->[0] => $_->[1]} <$FILE>; } my %a = get_file '/tmp/first.txt'; my %b = get_file '/tmp/second.txt'; { no warnings 'uninitialized'; print "$_\n" for grep {$_} @a{keys %b}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: comparing 2 columns
by GotToBTru (Prior) on Jan 04, 2016 at 15:07 UTC | |
|
Re: comparing 2 columns
by kennethk (Abbot) on Jan 04, 2016 at 16:43 UTC | |
|
Re: comparing 2 columns
by Corion (Patriarch) on Jan 04, 2016 at 15:07 UTC | |
|
Re: comparing 2 columns
by kikuchiyo (Hermit) on Jan 04, 2016 at 19:52 UTC | |
by 2015_newbie (Novice) on Jan 05, 2016 at 05:09 UTC | |
by AnomalousMonk (Archbishop) on Jan 05, 2016 at 05:29 UTC |