in reply to Combining hashes of hahses?
# Read in DNA file (file.1) my %dna = (); open my $file1, "<", "./file.1" or die "Can't open file.1: $!"; while (<$file1>) { chomp; next if $. == 1; my ($key, $val) = split /\s+/; $dna{$key} = $val; } # Read in MORPH file (file.2) my %morph = (); open my $file2, "<", "./file.2" or die "Can't open file.2: $!"; while (<$file2>) { chomp; next if $. == 1; my ($key, $val) = split /\s+/; $morph{$key} = $val; } # Get sorted, unique keys from above my %allkeys = map { $_ => 1 } (sort keys %dna, sort keys %morph); my @uniq_species = sort keys %allkeys; my %records = (); foreach (@uniq_species) { $records{$_} = (defined $dna{$_}) ? $dna{$_} : "?"x14; $records{$_} .= (defined $morph{$_}) ? $morph{$_} : "?"x18; } foreach (sort keys %records) { print "$_ $records{$_}\n"; }
---
echo S 1 [ Y V U | perl -ane 'print reverse map { $_ = chr(ord($_)-1) } @F;'
Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Combining hashes of hahses?
by erio (Initiate) on Nov 07, 2007 at 18:41 UTC |