in reply to Re: Can't use string ("0") as a HASH ref while "strict refs" problem
in thread Can't use string ("0") as a HASH ref while "strict refs" problem

this a output of part of the dumper :

 print Dumper(\%hash_geno_group{$sample_geno_group});

after :

 next if ($cds eq "sample");

this my output :

'XM_010928396.1 ' => { 'ambigu' => 156, 'BC11_III_.RG' => 75, 'rc' => 195, 'BC11_II_.RG' => 120 }, 'XM_010930511.1 ' => { 'BC11_II_.RG' => 258, 'ambigu' => 4, 'rc' => 1074, 'BC11_III_.RG' => 816 }, 'XM_010922249.1 ' => { 'BC11_II_.RG' => 0, 'ambigu' => 0, 'BC11_III_.RG' => 0, 'rc' => 0 }, 'XM_010912985.1 ' => { 'BC11_II_.RG' => 0, 'rc' => 0, 'ambigu' => 0 }, 'XM_010935705.1 ' => { 'BC11_II_.RG' => 0, 'ambigu' => 0, 'rc' => 0, 'BC11_III_.RG' => 0 }, 'XM_010939661.1 ' => { 'ambigu' => 0, 'BC11_III_.RG' => 0, 'rc' => 0, 'BC11_II_.RG' => 0 }, 'XM_010916522.1 ' => { 'BC11_II_.RG' => 0, 'rc' => 0, 'BC11_III_.RG' => 0, 'ambigu' => 0 }, 'XM_010930873.1 ' => { 'BC11_II_.RG' => 0, 'ambigu' => 0, 'rc' => 0, 'BC11_III_.RG' => 0 }, 'XM_010926039.1 ' => { 'BC11_II_.RG' => 0, 'BC11_III_.RG' => 0, 'rc' => 0, 'ambigu' => 0 }, 'XM_010928394.1 ' => { 'BC11_II_.RG' => 0, 'ambigu' => 0, 'BC11_III_.RG' => 0, 'rc' => 0 } }; Can't use string ("75") as a HASH ref while "strict refs" in use at te +st_fontion4.pl line 118.

can you see where is my problem ?

Replies are listed 'Best First'.
Re^3: Can't use string ("0") as a HASH ref while "strict refs" problem
by Corion (Patriarch) on Apr 12, 2016 at 10:02 UTC

    Perl already tells you where your problem is. In line 118.

    You haven't shown us the values of $cds or $RC, and you don't show us the line 118 from your script.

    From the error message Can't use string ("75") as a HASH ref and from the data you've showed, I can guess that your script tries to use the 75 from this hash entry:

    'XM_010928396.1 ' => { 'ambigu' => 156, 'BC11_III_.RG' => 75, 'rc' => 195, 'BC11_II_.RG' => 120 },

    Maybe you want to rerun your script using only this data, and then you should easily find out where your problem is.

    Maybe you want to reduce your deep diving through the data structure into several steps, giving Perl the chance to be more to the point with its error messages:

    # Convert this: values %{$hash_geno_group{$sample_geno_group}{$cds}{"rc"}} # to this: my $sample_geno_group_ref = $hash_geno_group{$sample_geno_group}; my $sample_cds = $sample_geno_group_ref->{$cds}; my $sample_rc = $sample_cds->{"rc"};

    Maybe also output the Dumper of each step so you can see where you are within your data structure.

      i fix my problem thanks for all this is the solution i found:

      foreach my $sample_geno_group(keys(%hash_geno_group)) { print $sample_geno_group. "\n"; foreach my $cds (keys %{$hash_geno_group{$sample_geno_group}}) { print "cds ".$cds. "\n"; next if ($cds eq "sample"); my $RC = 0; $RC += $hash_geno_group{$sample_geno_group}{$cds}{"rc"}; print "rc ".$RC. "\n"; #verification du nombre minimun de reads pour chaque groupe ge +notypique if ($RC < $seuil_min_classe) {