shabird has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks! Hope you are doing well I am trying to read a file which has three columns and store the content in a hash. Now i want to store the first column data as keys and third column data as a values, here is the file
GeneName GeneType Regulation APOL4 protein_coding up CYP2C8 protein_coding down NAALADL2 protein_coding NA NANOS3 protein_coding up C20orf204 protein_coding up MIR429 miRNA up MIR200A miRNA down MIR200B miRNA down CFL1P4 processed_pseudogene down AC091607.1 processed_pseudogene up RPL19P20 processed_pseudogene up SREK1IP1P1 processed_pseudogene down CCT5P2 processed_pseudogene up CHTF8P1 processed_pseudogene NA FAR1P1 processed_pseudogene NA AC067940.1 processed_pseudogene up AL662791.1 lncRNA up
here is my code which sets the second column as a value but i want to set the third column as a value in hash
open FILE1, "data.txt" or die; my %hash; while (my $line=<FILE1>) { chomp $line; (my $word1,my $word2) = split( /\s+/, $line); $hash{$word1} = $word2; } @values = values(%hash); print @values;
How can i split the second column out of the file?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Split a column
by choroba (Cardinal) on Apr 13, 2020 at 16:25 UTC | |
by shabird (Sexton) on Apr 13, 2020 at 16:35 UTC | |
by Fletch (Bishop) on Apr 13, 2020 at 16:51 UTC | |
by choroba (Cardinal) on Apr 13, 2020 at 17:08 UTC | |
by shabird (Sexton) on Apr 13, 2020 at 17:45 UTC | |
by Fletch (Bishop) on Apr 13, 2020 at 18:03 UTC | |
by choroba (Cardinal) on Apr 13, 2020 at 18:00 UTC | |
by AnomalousMonk (Archbishop) on Apr 13, 2020 at 18:44 UTC | |
Re: ead a file which has three columns and store the content in a hash
by BillKSmith (Monsignor) on Apr 16, 2020 at 15:32 UTC | |
Re: ead a file which has three columns and store the content in a hash
by leszekdubiel (Scribe) on Apr 14, 2020 at 18:24 UTC | |
by haukex (Archbishop) on Apr 14, 2020 at 18:28 UTC |