Two questions on die{} and writing error to file - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming > Perl » Two questions on die{} and writing error to file


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 07-27-2006   #1 (permalink)
samuel
Member
 
Join Date: Jun 2006
Age: 33
Posts: 34
Default Two questions on die{} and writing error to file

Hi there!

I'm writing my first perl code and would like to have my program's result to a file. I'm handling errors like this:
...
else {
die "file is not valid at line $Num! ";
}
How can I write this error to a (log)file before my program dies? Should I use this in each case when I have die{} ?
else {
open ($LOG_FILE_HANDLE, ">mylog.log" ) || die "main() : mylog.log" ;
print $LOG_FILE_HANDLE "Error: file is not valid at line $Num!";
close( $LOG_FILE_HANDLE) ;
Or is there a professional solution for this?

Another question is, that if my program is running, and for some reason it terminates / hangs (because of interruption, resetting computer due to power-cut, shut down..etc) how can I write to a logfile that a failure occured and the program was terminated?
I'm using logfile handling as above.

Thanks
samuel
samuel is offline   Reply With Quote


Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing Services articlewriter Services 12 05-30-2007 11:27 AM
Content Writing Service. kibeth Content 4 03-23-2007 07:00 PM
Writing Services kconnections General Business Issues 4 10-04-2006 05:25 PM
What HTTP error is generated when there is an error in an ASP page? agaba175 ASP 0 08-05-2006 08:25 PM
Writing Off My Car for Tax? jordan General Business Issues 6 07-31-2006 11:06 PM


footer left
All times are GMT. The time now is 09:14 PM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6

Advertising | Credit Card | Mortgage Loans | Online Advertising | Credit Cards

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49