Then i have an array [001, 002, 003, ...] and i want to match the keys {001} with the array [001] and replace it with the hash's value...
[blah blah blah, 002, 003, ...]
this is what i have, but obviously doesn't work...
open (ALL2, "file.txt") ¦¦ die print "can't open"; THANKS ! [1][edited by: phranque at 8:35 am (utc) on Aug. 4, 2009]
while (<ALL2>){
chomp;
@Line = split(/\t/);
if ( $hash{$key} eq $Line){
s/$Line[1]/$Genes{$value}/g;
}
[edit reason] disabled graphic smileys ;) [/edit]
i turned that into an array with:
@Line = split(/\t/);
i made a Hash out of my other text file#2 which looks like:
001 yadda-yadda
002 yadda-yadda
if ($_ =~ /something/){
my $key = $1.;
my $genes = $3;
if ( defined ( $Genes{$key})){
$Genes{$key} = $3;
}
NOW, i want to take the value "blah-blah" and and substitute it in file#1
and i'm trying this, but doesn't work...
@Line = split(/\t/);
if ( $hash{$key} eq $Line[1] ){
s/$Line[1]/$Genes{$value}/g;
so that my file#1 ends up looking like
1 yadda-yadda 002 blah-blah