You appear to be having trouble boiling the problem down to code that reliably reproduces the problem. I actually don't see how you wind up with a value of undef for a key of %count. There is probably something that you are not showing us.

This is an advanced concept, but it is possible to have a subroutine executed when a Perl warning happens. You can add this code below to your code. At the first warning message, this code should dump the subroutine's input parameters to match_query. match_query($indexfile,$queryseq) and then exit.

The results of this are what we want. When the error happens, what are the values of $index_file and $queryseq? From that, this error can be replicated.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; $SIG{'__WARN__'} = \&stop_n_report; #add this my $indexfile = { 'GCTCAGGA' => '4', 'AGCGTAGC' => '5', }; my $queryseq='something'; my $undef_val; #simulation of your code print "$undef_val"; #simulation of your code to produce an error sub stop_n_report ## add this { print "some kind of warning detected: @_\n"; print "Dumping input data\n"; print "Dumping indexfile:\n"; print Dumper $indexfile; print "query=$queryseq\n"; exit; } __END__ some kind of warning detected: Use of uninitialized value $undef_val i +n string at C:\Projects_Perl\testing\sigwarn.pl line 16. Dumping input data Dumping indexfile: $VAR1 = { 'GCTCAGGA' => '4', 'AGCGTAGC' => '5' }; query=something

In reply to Re: Help with function, count matches and store in hash & retrieve sorted by Marshall
in thread Help with function, count matches and store in hash & retrieve sorted by Pathogenomix

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.