For logging, use something like Log::Any. In the line just before where the error is occuring, I would $log->debugf("DIcas_text='%s', HR=%s", \@HR); -- but that will add to your log whether or not there was an error.

As for debugging the problem: see perldiag#Use of uninitialized value: something in your @HR is coming up as an undef.

Armed with that knowledge, I might change the logging to something like what's used in the following SSCCE:

use warnings; use strict; use Log::Any qw($log); use Log::Any::Adapter ('File', './debug.log'); sub errcheck_array { my $logger = shift; my $prefix = shift; my $count = grep {!defined} @_; # count the number of undefined el +ements in input array return unless $count; # this line will prevent a log mes +sage unless there's an undef; comment it out to log _all_ calls, whet +her or not there's an undefined value $logger->debugf("%s: %d undefined values found in %s", $prefix, $c +ount, \@_); 1; } foreach my $hr ( [qw(a b c)], [a => undef, b => undef, 'c'], [qw(x y z +)] ) { my @HR = @$hr; my $DIcas_text = '%s' . ',%s'x$#HR; errcheck_array($log, "sprintf('$DIcas_text', \@HR)", @HR); my $EVmsg = sprintf($DIcas_text, @HR); print "STD OUTPUT> $EVmsg\ +n"; }

In reply to Re: Troubleshooting perl runtime errors by pryrt
in thread Troubleshooting perl runtime errors by lvirden

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.