chrisantha, try this:
#!/perl/bin/perl -w use strict; use Data::Dumper; my $hash = {}; for (<DATA>) { chomp; my @fields = split(/\s{4}/, $_); my @genes = split(',', $fields[3]); @genes = map { (split('\|'))[1] } @genes; push(@{$hash->{$fields[0]}}, \@genes); } print Dumper($hash); __DATA__ malS 1 forward malS|b3571, malT 1 forward malT|b3418, malXY 2 forward malX|b1621,malY|b1622, malZ 1 forward malZ|b0403, manA 1 forward manA|b1613, __OUTPUT__ $VAR1 = { 'malZ' => [ [ 'b0403' ] ], 'malS' => [ [ 'b3571' ] ], 'manA' => [ [ 'b1613' ] ], 'malXY' => [ [ 'b1621', 'b1622' ] ], 'malT' => [ [ 'b3418' ] ] };
Is this what you're looking for?
Updated: Added __OUTPUT__
In reply to Re: Getting data from a file (Operons and Genes).
by thezip
in thread Getting data from a file (Operons and Genes).
by chrisantha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |