Is this something like you wanted...
Giving:use warnings; use strict; use autodie; use Data::Dumper; my %result; my $lookup =<<'_LOOKUP'; CG32694-RD NM_167211 CG32694-RC NM_167210 CG32694-RA NM_167209 CG32694-RB NM_167212 CG33557-RA NM_001014730 _LOOKUP open LOOKUP, '<', \$lookup; my %lookup = map { local @_ = split; $_[1] => $_[0]; } <LOOKUP>; close LOOKUP; while (<DATA>) { local @_ = split /[][#!@\s]+/; @{ $result{$_[2]}}{ qw/cg val/} = ($lookup{$_[2]}, $_[$#_]); } warn Dumper \%result; __DATA__ 385#19126!NM_167210@[1103;1104] 2 386#19127!NM_167211@[1103;1104] 2 387#19128!NM_167212@[1103;1104] 2 438#1781!NM_135492@[1337] 1 442#1794!NM_001042886@[1349] 1
$ perl tst.pl $VAR1 = { 'NM_167212' => { 'cg' => 'CG32694-RB', 'val' => '2' }, 'NM_167210' => { 'cg' => 'CG32694-RC', 'val' => '2' }, 'NM_167211' => { 'cg' => 'CG32694-RD', 'val' => '2' }, 'NM_001042886' => { 'cg' => undef, 'val' => '1' }, 'NM_135492' => { 'cg' => undef, 'val' => '1' } };
In reply to Re: ISOLATE 2 ASSOCIATED FIELDS IN A TEXT FILE, then CONVERT the first into another based on a table of definitions
by Bloodnok
in thread ISOLATE 2 ASSOCIATED FIELDS IN A TEXT FILE, then CONVERT the first into another based on a table of definitions
by mupud
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |