#!/usr/bin/perl # http://perlmonks.org/?node_id=1133207 use strict; $| = 1; my $file1 = <<END; name1 ABCD name2 BCD name3 ASCDA name4 AAAAA END my $file2 = <<END; name1 0.2 name5 0.3 name4 0.0002 name7 0.222 END open my $one, '<', \$file1 or die "$! opening file1"; my %hash1 = split ' ', do{ local $/; <$one> }; close $one; #use YAML; print Dump \%hash1; open my $two, '<', \$file2 or die "$! opengin file2"; while(<$two>) { my ($key) = split; exists $hash1{$key} and print "$key $hash1{$key}\n"; } close $two;
In reply to Re: Retrieving Key and Value Hashes
by Anonymous Monk
in thread Retrieving Key and Value Hashes
by gghelpneeded
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |