On Fri, Aug 31, 2001 at 12:45:03AM -0400, Bryan C. Warnock wrote:
> Access to the source code.  

Already got that.  

    use Fcntl qw(:seek);
    seek DATA, 0, SEEK_SET;
    @code = <DATA>;


> We're going to be carrying it around, unless we 
> strip it.  We might as well put it to good use within error messages and the 
> like.  If an error points me to foo:356, I want my DIE handler to dump the 
> code surrounding that.
<snip>
> Compilation time.  For each of my compilation units, I would like to know 
> when it was compiled.  Compilation unit scoped. 

You can already do that.  Override CORE::GLOBAL::require/use/do.

Your overridden require/use/do can mark the time it was called *and*
remember the *DATA filehandles.  On an error, you can do:

    use Fcntl qw(:seek);
    $SIG{__DIE__} = sub {
        my($pack, $file, $line) = caller;

        if( my $data_fh = $DATA{$file} ) {
            my $orig_pos = tell $data_fh;

            seek $data_fh, 0, SEEK_SET;
            my @code = <$data_fh>;

            print STDERR @_;
            print STDERR @code[$line-2..$line+2];

            seek $data_fh, $orig_pos, SEEK_SET;
        }

    }

When will we be seeing the CPAN module for this?


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <[EMAIL PROTECTED]>       Kwalitee Is Job One
I know you get this a lot, but what's an unholy fairy like you doing in a
mosque like this?

Reply via email to