in reply to Help with function, count matches and store in hash & retrieve sorted
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
|
|---|