in reply to reading RNA codons into hash

Not sure what your problem is, but that's way to much code :D

I think you want something like this:

#!/usr/bin/env perl use strict; use warnings; our %code; while (<>){ chomp; my @tokens = split " ", $_; my $protein = shift @tokens; for my $token (@tokens) { $code{$token} = $protein; } } foreach my $key (sort keys %code){ print "$key\t$code{$key}\n"; }

Using this input file:

A ABC DEF GHI JKL B QRS TUV WXY C EYE LUV YOU

I get this result:

ABC A DEF A EYE C GHI A JKL A LUV C QRS B TUV B WXY B YOU C

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^2: reading RNA codons into hash
by ic23oluk (Sexton) on Jul 13, 2017 at 10:13 UTC
    Thank you, too!