Edward Wijaya wrote:
Hi,
Hello,
I have a file that contain this:
GCTTGACGG: GCTTGACGA,GCTTGACCG,GCTTGACGA
CTTGAAGAG: CTTGACGAG,CTTGACGAG,CTTGACGAG,CTTGACGAG,CTTGAAGAA
CTTGACGAA: CTTGACGAG,CTTGACGAG,CTTGACGAG,CTTGACGAG
My problem is that I want to create hash of and array.
Where the 'word' to the left of the colon is the hash name
and the 'words that comes with commas' after the colon
is the element.
Is there any efficient way to do this?
Sure,
open DNA, '/path/to/file' or die $!;
my %dna_info = ();
while(<DNA>) {
chomp;
my ($k,$v) = $_ =~ m/^(\w+)\: (.*)/;
$dna_info{$k} = split /,/, $v;
}
close DNA;
perldoc open
for more details
Thanks so much for your time.
HTH
Lee.M - JupiterHost.Net
Hope to hear from you again.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>