in reply to fetching from a hash
Output:use Modern::Perl; my %data = ( 'LB2241-RCC' => { 'rs6557634' => { 'plex' => 'W30467', 'gt' => 'T', 'file' => 'file1.csv' }, 'rs1032807' => { 'plex' => 'W30569', 'gt' => 'G', 'file' => 'file1.csv' }, } ); foreach my $sample ( keys %data ) { foreach my $snpid ( keys %{ $data{$sample} } ) { my $plex = $data{$sample}->{$snpid}{'plex'}; my $gt = $data{$sample}->{$snpid}{'gt'}; my $file = $data{$sample}->{$snpid}{'file'}; open my $FH, '<', "./$file" or die $!; my $content = join ', ', <$FH>; say "$plex, $sample, $gt, $content"; } }
W30569, LB2241-RCC, G, T,T,C,CA,GT,T,GA,C,A,G,CT,T,T,CA,AG,TC,G,GA,C,T +C,CT,AG,AG,C,GT,GA,G,GA,T W30467, LB2241-RCC, T, T,T,C,CA,GT,T,GA,C,A,G,CT,T,T,CA,AG,TC,G,GA,C,T +C,CT,AG,AG,C,GT,GA,G,GA,T
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|