#!/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 in string at C:\Projects_Perl\testing\sigwarn.pl line 16. Dumping input data Dumping indexfile: $VAR1 = { 'GCTCAGGA' => '4', 'AGCGTAGC' => '5' }; query=something