Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How to determine current line executing in Script

by Anonymous Monk
on Dec 04, 2008 at 12:56 UTC ( [id://727957]=note: print w/replies, xml ) Need Help??


in reply to How to determine current line executing in Script

Make use of warn, $SIG{__WARN__} and END {...}. If the argument to warn doesn't end with a new line ( warn $x." "; ) then the line number will be appended. In $SIG{__WARN__} do a "push(@log,"@_");". In the END block print @log. You probably should add a $SIG{__DIE__} where you also do the "push(@log ..." before you re-raise the die. That way you'll get a log if you "die".
  • Comment on Re: How to determine current line executing in Script

Replies are listed 'Best First'.
Re^2: How to determine current line executing in Script
by Anonymous Monk on Dec 04, 2008 at 14:08 UTC
    #!/usr/bin/perl use strict; use warnings; my @log="\n"; BEGIN { $SIG{__WARN__}=sub { push(@log,"@_"); }; $SIG{__DIE__}=sub { push(@log,"@_"); }; } # BEGIN END { if (@log) { print @log; }; } # END warn "a warning "; my $warning="just another warning\n"; warn $warning." "; die "death by request";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://727957]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 21:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found