hello i have this code :

my $sample_cds_genotype = $prefixe ."_cds_genotype"; my $sample_cds_RT = $prefixe ."_cds_RT"; my $sample_cds_R1 = $prefixe ."_cds_R1"; my $sample_cds_R2 = $prefixe ."_cds_R2"; my %hash_sample_cds_genotype; my %hash_sample_cds_RT; my %hash_sample_cds_R1; my %hash_sample_cds_R2; my %hash_geno_group; my %hash_read_p1_count; my %hash_read_p2_count; #alimentation du hash des groupe genotypique connu pour les echatillo +ns open(GENOTYPED,"<$list_geno") or die ("Cannot open $list_geno\n"); while (defined(my $_ = <GENOTYPED>)) { my @geno_group_infos = split(m/\t/,$_); next if ($_ =~ m/^ECHANTILLON/); chomp($_); my $sample_nm = $geno_group_infos[0]; my $sample_geno_group = $geno_group_infos[1]; $hash_geno_group{$sample_geno_group}{"sample"}=$sample_nm; + } close(GENOTYPED); print Dumper(\%hash_geno_group); #String des fichiers inputs foreach my $fichier (@fichiers) { my $filename = $fichier; my $sample_name; #alimentation des hashs de resultat avec cet echatillon open(RESULTAT,"<$filename") or die ("Cannot open $filename\n"); while (defined(my $_ = <RESULTAT>)) { $sample_name = $filename."\t"; #my @attribut_name = split(m/out_/,$sample_name); #$sample_name = $attribut_name[1]."\t"; my @resutat_infos = split(m/\t/,$_); next if ($_ =~ m/^CDS/); chomp($_); my $cds = $resutat_infos[0] ."\t"; my $reads_p1 =$resutat_infos[1]."\t"; my $reads_p2 =$resutat_infos[2]."\t"; my $count_reads_p1 =$resutat_infos[3]; my $count_reads_p2 =$resutat_infos[4]; my $count_reads_ambigu =$resutat_infos[5]; my $count_reads_classe =$resutat_infos[6]; my $reads_totaux =$resutat_infos[8]."\t"; $hash_sample_cds_RT{$cds}{$sample_name} = $reads_totaux ; $hash_sample_cds_R1{$cds}{$sample_name} = $reads_p1 ; $hash_sample_cds_R2{$cds}{$sample_name} = $reads_p2 ; $hash_read_p1_count{$cds}{$sample_name} = $count_reads_p1; $hash_read_p2_count{$cds}{$sample_name} = $count_reads_p2; foreach my $group(keys(%hash_geno_group)) { print $group."\n"; if (exists($hash_geno_group{$group}{"sample"}{$sample_name +})) { $hash_geno_group{$group}{$cds}{"ambigu"} += $count_rea +ds_ambigu; $hash_geno_group{$group}{$cds}{"rc"} += $count_reads_c +lasse; $hash_geno_group{$group}{"sample"}{$sample_name}=($cou +nt_reads_p1+$count_reads_p2); } } } close(RESULTAT); print "Finished\n"; }

my output is :

[foulquie@node6 test]$ perl test_fontion4.pl BC list_geno_palm_51_list +e_genotype test 30 1 Use of my $_ is experimental at test_fontion4.pl line 44. Use of my $_ is experimental at test_fontion4.pl line 68. keys on reference is experimental at test_fontion4.pl line 187. keys on reference is experimental at test_fontion4.pl line 211. keys on reference is experimental at test_fontion4.pl line 235. keys on reference is experimental at test_fontion4.pl line 259. $VAR1 = { 'genotype13' => { 'sample' => 'BC13_IV_.RG' }, 'genotype11' => { 'sample' => 'BC11_III_.RG' }, 'genotype14' => { 'sample' => 'BC14_III_.RG' }, 'genotype16' => { 'sample' => 'BC16_III_.RG' }, 'genotype21' => { 'sample' => 'BC21_V_.RG' }, 'genotype24' => { 'sample' => 'BC24_IV_.RG' }, 'genotype1' => { 'sample' => 'BC1_IV_.RG' }, 'genotype10' => { 'sample' => 'BC10_III_.RG' }, 'genotype23' => { 'sample' => 'BC23_III_.RG' }, 'genotype9' => { 'sample' => 'BC9_IV_.RG' }, 'genotype8' => { 'sample' => 'BC8_IV_.RG' }, 'genotype4' => { 'sample' => 'BC4_II_.RG' }, 'genotype22' => { 'sample' => 'BC22_IV_.RG' }, 'genotype20' => { 'sample' => 'BC20_IV_.RG' }, 'genotype15' => { 'sample' => 'BC15_III_.RG' }, 'genotype7' => { 'sample' => 'BC7_IV_.RG' }, 'genotype6' => { 'sample' => 'BC6_IV_.RG' }, 'genotype3' => { 'sample' => 'BC3_III_.RG' }, 'genotype12' => { 'sample' => 'BC12_IV_.RG' }, 'genotype19' => { 'sample' => 'BC19_IV_.RG' }, 'genotype17' => { 'sample' => 'BC17_V_.RG' } }; genotype13 Can't use string ("BC13_IV_.RG") as a HASH ref while "strict refs" in +use at test_fontion4.pl line 92, <RESULTAT> line 2.

my problem are the obvious error message but also my hash in the dumper should give more that one valeur for 'sample' like : 'genotype17' => { 'sample' => 'BC17_III_.RG' => 'BC17_V_.RG' but the key sample had only have the last value why ? plz help me thanks


In reply to Can't use string as a HASH ref problem by etricaen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.