Not a beginner's question, but I don't know what other mailing list to
use.  Please direct me accordingly.

I have a Perl program that defines numerous functions by eval'ing a
string (read from an external file).  I have a comprehensive
$SIG{__WARN__} handler but for errors in these functions all I get is
'(eval \d+)' for the file name containing the error.

So, here is my first question -- in my $SIG{__WARN__} handler, if I get
a warning from a (eval \d+) file, can I figure the name of the function
that was being executed when the warning was triggered?

But I have a better solution I'm hoping for.  The number inside of the
(eval \d+) description seemed to increment once per eval, and by looking
at the Perl source code sure enough it seems to be tracked by the
PL_evalseq variable.

If I can find out what number was assigned to my eval statement, I could
remember this and relate later warnings as appropriate.  Something like
this:

my $str = "sub Blah {...}";
my @eval_ids;
eval $str;
my $id = ????????
$eval_ids[$id] = $str;

$SIG{__WARN__} = sub {
   if ($_[0] =~ /\(eval (\d+)\)/) {
      print "Error was in code: $eval_ids[$1]\n";
   }
};

Any help with this, pointers to other mailing lists, or alternative
approaches would be greatly appreciated.

FYI the strings being eval'd come from external files that are split
into section and are eval'd in several pieces.

-- 
Kirk Bauer <[EMAIL PROTECTED]>
http://linux.kaybee.org | www.autorpm.org | www.logwatch.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to